Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

514
Views
angular disable weekends on mat-date-range

I wanted to disable weekends on a calendar , I am using date range but I cant seem to make it work , anyone has an idea ?

the issue

 Can't bind to 'matDatepickerFilter' since it isn't a known property of 
'input'.

#ts code

 weekendsDatesFilter = (d: Date): boolean => {
    const day = d.getDay();

    /* Prevent Saturday and Sunday for select. */
    return day !== 0 && day !== 6 ;
}

#html code

<mat-form-field appearance="fill" >
                                                <mat-label>
                                                    SELECT DATES
                                                </mat-label>
                                                <mat-date-range-input [min]="currentDate" [rangePicker]="picker">
                                                    <input  [matDatepickerFilter]="weekendsDatesFilter" matStartDate [(ngModel)]="model.proposedDateStart" placeholder="Start Date" required >
                                                    <input  [matDatepickerFilter]="weekendsDatesFilter" matEndDate [(ngModel)]="dateEnd" placeholder="End Date" required>
                                                </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>
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

https://material.angular.io/components/datepicker/api#MatDateRangeInput

Function that can be used to filter out dates within the date range picker.

@Input()
dateFilter: DateFilterFn<D>

Let's use a callback function to filter out dates that should be disabled.

@Component({
  selector: 'date-range-picker-overview-example',
  templateUrl: 'date-range-picker-overview-example.html',
  styleUrls: ['date-range-picker-overview-example.css'],
})
export class DateRangePickerOverviewExample {
  weekendsDatesFilter = (d: Date): boolean => {
    const day = d.getDay();
    /* Prevent Saturday and Sunday for select. */
    return day !== 0 && day !== 6;
  };
}
<mat-form-field>
  <mat-label>Enter a date range</mat-label>
  <mat-date-range-input [rangePicker]="picker" [dateFilter]="weekendsDatesFilter">
    <input matStartDate matInput placeholder="Start date" >
    <input matEndDate matInput placeholder="End date">
  </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>

Working example: https://stackblitz.com/edit/angular-byrmnt?file=src%2Fapp%2Fdate-range-picker-overview-example.ts

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!