Angular ng-pick-datetime disabled the weekend dates

201 views Asked by At

I'm working on Angular and using ng-pick-datetime plugin. I want to disable the dates of every weekend(Saturday & Sunday). I tried to search but couldn't find any solution.

<input [owlDateTime]="dt1" class="form-control" formControlName="currentDate" [owlDateTimeTrigger]="dt1" placeholder="mm/dd/yyyy" />
        
<owl-date-time #dt1 pickerType="calendar"></owl-date-time>
1

There are 1 answers

0
Eugene_Kr On

From the docs: https://daniel-projects.firebaseapp.com/owlng/date-time-picker#date-time-validation

<input [owlDateTimeFilter]="myFilter" [owlDateTimeTrigger]="dt" [owlDateTime]="dt">
<owl-date-time #dt></owl-date-time>

export class MyComponent {
  public myFilter = (d: Date): boolean => {
    const day = d.getDay();
    // Prevent Saturday and Sunday from being selected.
    return day !== 0 && day !== 6;
  }
}