Owais Ahmed Khan
Owais Ahmed Khan

Reputation: 268

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>  

Upvotes: 0

Views: 694

Answers (1)

AlTheLazyMonkey
AlTheLazyMonkey

Reputation: 1242

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

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

Upvotes: 1

Related Questions