I am using material datepicker component, I want restrict the future dates in datepicker component, While surfing i found the solution solution1 ,solution2, but these solution suits good for normal datepicker.But i want to restrict in material datepicker.If possible please provide the solution in this DEMO.
MatDatepickerInput has an @Input
for this
@Input()
max: D | null
See this short example:
<mat-form-field>
<input matInput [matDatepicker]="picker" [max]="today" placeholder="Choose a date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
TS file:
today = new Date();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With