在 FullCalendar 中为每一天添加图标 Angular

Add Icon to each day in FullCalendar Angular

我有一个 FullCalendar,我想为每一天添加图标。请注意,我已经对这个问题进行了研究,包括关于 SO 的这些答案:

  1. this 问题是似乎没有 dayRender 方法。

  2. 如果事件是单日的,效果很好。不适用于多日活动

  3. 与 1.

    相同的问题
  4. 我检查了 Documentation of FullCalendar/Angular and the given examples

方法 dayRender 不存在或者我无法正确调用它。

我目前在做什么:

 <full-calendar ... (dayRender)="dayRender(date, cell)"></full-calendar>

请注意:

  1. 我只发布了相关部分
  2. 我想给每一天添加图标
  3. 我想让它们可点击

这个答案只解决了2.。我仍然无法使图标可点击。

要实现此功能,您需要像这样添加事件侦听器:

(dayRender)="dayRender($event)"

然后在 你的 dayRender 函数中,你会收到一个具有以下属性的对象:date(日期类型),el(这是特定元素)和 view1(TimeGridView 类型)。

要为每一天添加一个图标,您需要这样的东西:

dayRender(dayToBeRendered) {
  const imgElement: HTMLElement = document.createElement('img');
  // add the correct attributes to your img element
  dayToBeRendered.el.appendChild(divElement);
}