简体   繁体   English

Angular 11:如何在 Fullcalendar V5 中重新获取(从后端更改事件时)事件?

[英]Angular 11 : How to refetch (when events are changed from backEnd) Events in Fullcalendar V5?

I am working on "@fullcalendar/angular": "^5.5.0",我正在研究"@fullcalendar/angular": "^5.5.0",

I am unable to rerender the events that are subscribed from an API call.我无法重新呈现从 API 调用订阅的事件。 I searched everywhere but, nothing is working... Please help..我到处搜索,但没有任何工作...请帮助..

Here is the code:这是代码:

calendar.component.html calendar.component.html

  <full-calendar #calendar [options]="calendarOptions"></full-calendar>

calendar.component.ts日历组件.ts


  events = [];

  calendarOptions: CalendarOptions = {
    headerToolbar: {
      left: 'prev,next today',
      center: 'title',
      right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
    },
    initialView: 'dayGridMonth',
    initialEvents: this.events, // How to render calendar when events changes???
    weekends: true,
    // events: this.events,
    // lazyFetching: true,
    editable: true,
    selectable: true,
    selectMirror: true,
    dayMaxEvents: true,
    select: this.handleDateSelect.bind(this),
    eventClick: this.handleEventClick.bind(this),
    eventsSet: this.handleEvents.bind(this)

  };

  ngOnInit(): void {
    this._calendarService.onDataChanged.subscribe(res => {
      this.events = res;
    });
}

Final call: How to render the calendar when events change???最终通话:事件发生变化时如何渲染日历???

When I used full-calendar I fetched events not through options but like this:当我使用全日历时,我不是通过选项获取事件,而是像这样:

<full-calendar [events]="calendarEvents">
</full-calendar>

It worked.有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM