ngx Bootstrap Datepicker only to allow first day of a month

Viewed 86

I want only the first day of each upcoming month to be selectable. All other days should be disabled.

Input Field in HTML:

<input class="form-control" bsDatepicker placement="top" [bsConfig]="bsDatepickerConfig" [minDate]="minDate">

bsConfig:

export const bsConfig = {
   dateInputFormat: 'DD.MM'YYYY',
   containerClass: 'theme-blue',
   showClearButton: true
}

minDate:

minDate = new Date();

What do I have to add to the bsConfig?

1 Answers

You can use datesEnabled property. Create the enabledDates array dynamically for 1st date of each month

.TS

 enabledDates = [
    new Date('2020-02-06'),
    new Date('2020-02-08'),
    new Date('2020-02-11'),
 ];

.HTML

<input class="form-control" bsDatepicker [datesEnabled]="enabledDates" [bsConfig]="bsDatepickerConfig" >
Related