NgbDatepicker禁用某些日期

时间:2018-10-18 12:07:59

标签: javascript angular typescript ngb-datepicker

我正在尝试禁用日历中的某些日期。但是似乎datepicker组件在父组件的变量已初始化之前加载。

days = [1, 2, 3]

const isDisabled = (date: NgbDateStruct, current: {month: number}) => this.dates.includes(day.date.day) // cannot read property of undedifned

const isDisabled = (date: NgbDateStruct, current: {month: number}) => [1, 2, 3].includes(day.date.day) // this is ok

<ngb-datepicker [minDate]="{year: 2010, month: 1, day: 1}"
                [maxDate]="{year: 2048, month: 12, day: 31}"
                [markDisabled]="isDisabled">
</ngb-datepicker>

0 个答案:

没有答案