I want to update and make yesterday's date appear as the date in mat-datepicker.
I tried to implement it the following way but it was not successful. My code -
app.component.html
<mat-form-field class="example-full-width" [floatLabel]="hideLabel">
<input matInput [formControl]="onlineDate" name="onlineDate" [max]="currentDate"
[matDatepicker]="picker" required placeholder="Online Date "
autocomplete="off" />
<mat-datepicker-toggle matSuffix [for]="picker">
</mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
app.component.ts
export class ApplicantComponent implements OnInit, AfterViewInit {
onlineDate: FormControl;
currentDate = new Date();
today = new Date()
yesterday = new Date();
constructor(
this.onlineDate = new FormControl(this.yesterday.setDate(this.yesterday.getDate() - 1))
}
}
With the above code, I am unable to get any date in display. Screenshot for reference-