问题描述
有什么方法可以在 BsDatepickerInlineDirective 中禁用一周中的几天。我查看了此指令 ngx-bootstrap 的文档。
解决方法
在 Angular 10 中使用 ngx-bootstrap
禁用工作日,试试这个 -
daysDisabled
使用数组设置,星期日被视为一周的第一天,因此值为 0。
HTML -
<input type="text" placeholder="Datepicker" class="form-control"
[daysDisabled]="[1,2,3,4,5]" bsDatepicker>
对于“禁用日期”css -
.ts -
@Component({
...
encapsulation: ViewEncapsulation.None
})
.css -
.bs-datepicker-body table td span.disabled {
color: #fff;
background-color: red;
}
输出(禁用工作日)-
禁用特定日期 -
datesDisabled
使用数组设置,日期格式 - 'mm/dd/yyyy' OR 'yyyy/mm/dd'
HTML -
<input type="text" placeholder="Datepicker" class="form-control"
[datesDisabled]="dates" bsDatepicker>
.ts -
dates = [new Date('02-06-2021')];
输出(禁用日期为 2021 年 2 月 6 日)-