angularbootstrap-4ngx-bootstrapdatefilter

How to Disable Weekends (Sat & Sun) using ngx-bootstrap BsDatePicker?


I m using 'ngx-bootstrap bsdatepicker' in angular 8 application. i need to disable all weekends(Sat and Sunday) and national holidays .is there any possible way to do ?


Solution

  • To disable specific weekdays you can do the following:

    <input class="form-control" placeholder="Daterangepicker" bsDaterangepicker [daysDisabled]="[6,0]">
    

    For all the other days you want to disable you can manually add them with:

        <input type="text"
               placeholder="Datepicker"
               class="form-control"
               bsDatepicker
               [datesDisabled]="disabledDates">
    
      disabledDates = [
        new Date('2020-02-05'),
        new Date('2020-02-09')
      ];
    

    Further documentation can be found at https://valor-software.com/ngx-bootstrap/#/datepicker