NgBootstrap DatePicker如何传入DayTemplateContext TemplateRef
How to pass in DayTemplateContext TemplateRef of NgBootstrap DatePicker
我想使用 NgBootstrap TimeRange Picker (https://ng-bootstrap.github.io/#/components/datepicker/examples)
唯一还没有工作的是我必须提交 DayTemplateContext TemplateRef 的范围的显示。像这样:
constructor(config: NgbDatepickerConfig) {
config.displayMonths = 3;
config.dayTemplate = this.thisIsTheVariableINeed; <--------
const todayNGB = calendar.getToday();
const today = new Date(todayNGB.year, todayNGB.month, todayNGB.day);
config.markDisabled = (date: NgbDateStruct) => {
const d = new Date(date.year, date.month - 1, date.day);
return d > today;
};
}
如何获取我在同一组件的 html 中定义的 TemplateRef:
<ng-template #asdasd let-date="date" let-focused="focused">
<span class="custom-day"
[class.focused]="focused"
[class.range]="isFrom(date) || isTo(date) || isInside(date) || isHovered(date)"
[class.faded]="isHovered(date) || isInside(date)"
(mouseenter)="hoveredDate = date"
(mouseleave)="hoveredDate = null">
{{ date.day }}
</span>
</ng-template>
我之所以要这样做是因为我没有意识到你可以在 html 中传入 [startDate] 而不是控制器。
我想使用 NgBootstrap TimeRange Picker (https://ng-bootstrap.github.io/#/components/datepicker/examples)
唯一还没有工作的是我必须提交 DayTemplateContext TemplateRef 的范围的显示。像这样:
constructor(config: NgbDatepickerConfig) {
config.displayMonths = 3;
config.dayTemplate = this.thisIsTheVariableINeed; <--------
const todayNGB = calendar.getToday();
const today = new Date(todayNGB.year, todayNGB.month, todayNGB.day);
config.markDisabled = (date: NgbDateStruct) => {
const d = new Date(date.year, date.month - 1, date.day);
return d > today;
};
}
如何获取我在同一组件的 html 中定义的 TemplateRef:
<ng-template #asdasd let-date="date" let-focused="focused">
<span class="custom-day"
[class.focused]="focused"
[class.range]="isFrom(date) || isTo(date) || isInside(date) || isHovered(date)"
[class.faded]="isHovered(date) || isInside(date)"
(mouseenter)="hoveredDate = date"
(mouseleave)="hoveredDate = null">
{{ date.day }}
</span>
</ng-template>
我之所以要这样做是因为我没有意识到你可以在 html 中传入 [startDate] 而不是控制器。