I have this simple form which is a range input from angular material. But the [min] and [max] date are not working. I tried to put in the first input, the second input and then both of them, but nothing works. I leave my code
<mat-form-field appearance="outline" class="w-100">
<mat-date-range-input [rangePicker]="picker" >
<input matStartDate placeholder="Start date" formControlName="start" [min]="minDate"
[max]="maxDate">
<input matEndDate placeholder="End date" formControlName="end" [min]="minDate"
[max]="maxDate">
</mat-date-range-input>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-date-range-picker #picker></mat-date-range-picker>
</mat-form-field>
I'm trying to get the max to be the same day, I mean today.
export class DateComponent implements OnInit, {
minDate: Date;
maxDate: Date;
constructor(private formBuilder: FormBuilder) {
const currentYear = new Date().getFullYear();
this.minDate = new Date(currentYear - 20, 0, 1);
this.maxDate = new Date();
}
}
But it's not working.