简体   繁体   中英

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

I am working on "@fullcalendar/angular": "^5.5.0",

I am unable to rerender the events that are subscribed from an API call. I searched everywhere but, nothing is working... Please help..

Here is the code:

calendar.component.html

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

calendar.component.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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