Date Component in American Standard in Angular

Asked

Viewed 61 times

-1

I have a Datepicker in my form that entering the date manually, the component is waiting for a date to be in American format and ends up with error.

inserir a descrição da imagem aqui

Selecting the date by the component itself, works normally.

inserir a descrição da imagem aqui

Following component code in HTML, I’m using Angular (7.2.3):

<mat-form-field appearance="outline" fxFlex="20">
  <mat-label>Data inicial</mat-label>
    <input matInput [matDatepicker]="pickerInicial" [(ngModel)]="startDate">
      <mat-datepicker-toggle matSuffix [for]="pickerInicial">
      <mat-icon matDatepickerToggleIcon>keyboard_arrow_down</mat-icon>
    </mat-datepicker-toggle>
  <mat-datepicker #pickerInicial></mat-datepicker>
</mat-form-field>

1 answer

0

Try adding the following to your module:

{provide: MAT_DATE_LOCALE, useValue: 'pt-BR'},

If this does not work try to search the documentation by date-picke provide formats and put the format (date mask) in the Brazilian standard

Browser other questions tagged

You are not signed in. Login or sign up in order to post.