ngModel make datePicker date of today return null

Viewed 1074

My date picker is set default to today, which benefit the status of what my code is running at the moment. I want to be able to pass the value of it so I use ngModel and it make my datePicker null. I found that ngInit can hard code default value but the problem is I don't know what represent dateTime.Now in ngInit.

<mat-form-field>
  <mat-label>Angular forms</mat-label>
  <input matInput [matDatepicker]="picker1" [formControl]="date" [(ngModel)]="datePicker">
  <mat-datepicker-toggle matSuffix [for]="picker1"></mat-datepicker-toggle>
  <mat-datepicker #picker1 [(ngModel)]="datePicker"></mat-datepicker>
</mat-form-field>
1 Answers
Related