Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable particular dates in Angular Material Date picker

I'm trying to us Angular 6 Material datepicker for one of my projects. I need to disable particular dates or give the user an option to choose particular dates(can be some random dates).

<mat-card>
    <input matInput [matDatepicker]="picker" placeholder="Choose a date">
    <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
    <mat-datepicker #pickers></mat-datepicker>
    <app-date-picker></app-date-picker>
  </mat-card>
``
like image 649
Shashank Avatar asked Mar 17 '26 05:03

Shashank


1 Answers

You have to use date validation:

https://material.angular.io/components/datepicker/overview#date-validation

So you can use min and max properties or matDatepickerFilter for more specified filters (probably better for your case). You can check two examples in the link above (first min and max, 2nd with matDatepickerFilter).

like image 94
Patryk Łucka Avatar answered Mar 19 '26 21:03

Patryk Łucka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!