Skip to content

Disable Weekends on ng2-date-picker

I am looking for a function that can disable weekends on my datepicker. I know that I can use isDayDisabledCallback to disable dates but how can I only disable weekends.

<dp-date-picker [(ngModel)]="selectedDate" [config]="datePickerConfig"></dp-date-picker>  

Answer

In the configuration you can set the callback isDayDisabledCallback like that for exclude Saturday and Sunday.

config = {
  isDayDisabledCallback: (date) => [0, 6].includes(date.day()) 
};