Search code examples
htmlangularangularjsdatepicker

How can i fix this MatDatepicker problem?


When i put date(yyyy-mm-dd) into the first input it works, but when i copy the same date into the second input, it doesnt work and underline it with red color. Code:

<mat-form-field>
                            <input matInput [matDatepicker]="paymentDateFrom" placeholder="Дата платежа с"
                                   [(ngModel)]="MT102Criteria.paymentDateFrom" name="paymentDateFrom">
                            <mat-datepicker-toggle matSuffix [for]="paymentDateFrom"></mat-datepicker-toggle>
                            <mat-datepicker #paymentDateFrom></mat-datepicker>
                          </mat-form-field>
                        <button mat-icon-button (click)="resetSearchField('mt102_paymentDateFrom')">
                          <mat-icon class="reset-searchfield-btn">clear</mat-icon>
                        </button>
<mat-form-field>
                        <input matInput [matDatepicker]="paymentDateTo" placeholder="Дата платежа По"
                               [(ngModel)]="MT102Criteria.paymentDateTo" name="paymentDateTo">
                        <mat-datepicker-toggle matSuffix [for]="paymentDateTo"></mat-datepicker-toggle>
                        <mat-datepicker #paymentDateTo></mat-datepicker>
                      </mat-form-field>
                      <button mat-icon-button (click)="resetSearchField('mt102_paymentDateTo')">
                        <mat-icon class="reset-searchfield-btn">clear</mat-icon>
                      </button>


export class MT102Criteria {
  paymentDateFrom: string;
  paymentDateTo: string;
}

enter image description here

dont know how to fix this issue, need a help


Solution

  • Console.log and check type of the value of the first and second input, if that so , you should change the type.