【问题标题】:How to pass in DayTemplateContext TemplateRef of NgBootstrap DatePicker如何传入 NgBootstrap DatePicker 的 DayTemplateContext TemplateRef
【发布时间】:2018-04-26 14:02:53
【问题描述】:

我想使用 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>

【问题讨论】:

    标签: angular angular5 ng-bootstrap


    【解决方案1】:

    之所以要这样做是因为我没有意识到你可以在 html 中传入 [startDate] 而不是控制器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-31
      • 1970-01-01
      • 2022-06-13
      • 1970-01-01
      • 2018-05-01
      • 1970-01-01
      • 2019-07-21
      • 1970-01-01
      相关资源
      最近更新 更多