0

我正在使用https://mattlewis92.github.io/angular-calendar/#/kitchen-sink为日历创建事件。

根据文档事件创建如下:

events: CalendarEvent[] = [
    {
      start: subDays(startOfDay(new Date()), 1),
      end: addDays(new Date(), 1),
      title: 'A 3 day event',
      color: colors.red,
      actions: this.actions,
      allDay: true,
      resizable: {
        beforeStart: true,
        afterEnd: true
      },
      draggable: true
    },
    {
      start: startOfDay(new Date()),
      title: 'An event with no end date',
      color: colors.yellow,
      actions: this.actions
    },
    {
      start: subDays(endOfMonth(new Date()), 3),
      end: addDays(endOfMonth(new Date()), 3),
      title: 'A long event that spans 2 months',
      color: colors.blue,
      allDay: true
    },

在这里如何只为工作日创建事件?(例如周一到周五)。在 CalendarEvent[] 中,我没有排除周末的选项。

4

1 回答 1

0

<ng-template #customCellTemplate let-day="day" let-locale="locale">
  <div class="cal-cell-top">
    <span class="cal-day-badge" *ngIf="day.badgeTotal > 0"
      >{{ day.badgeTotal }}</span
    >
    <span class="cal-day-number"
      >{{ day.date | calendarDate:'monthViewDayNumber':locale }}</span
    >
  </div>
  **<small style="margin: 5px"
    >There are {{ day.events.length }} events on this day</small
  >**
</ng-template>

此自定义模板日属性在一周中的所有 7 天都有值 0,1,2,3,4,5,6。使用它我们可以控制周末的事件。

代码 :

<div *ngIf="day.day!=0 && day.day!=6">
  <small class="cal-event cal-month-veiw"></small>

</div>

于 2020-03-19T01:02:21.530 回答