我在过去的两三天里尝试过它。我按以下方式绑定fullcalendar events
,但事件未在第一次反映在日历上时无法解决为什么在bindEvents()
ngOnInIt()
方法发生这种情况
bindEvents() {
this.availibiltyOptions['events'] = [];
this.events.map((event) => {
this.availibiltyOptions['events'].push(event);
})
OR
this.availibiltyOptions['events'] = this.events;
这是我的HTML文件:
<angular2-fullcalendar #calendar [options]="availibiltyOptions">
</angular2-fullcalendar>
这是我的TS文件
availibiltyOptions: Object = {
eventClick: (event) => {
this.eventClick(event);
},
dayClick: (event) => {
this.daySelection(event);
},
dayRender: (date, cell) => {
this.cellUpdation(date, cell);
},
columnFormat: 'dddd',
viewRender: (view, element) => {
let viewSelectedMonth =
parseInt(moment(view.intervalStart['_i']).format('M'));
if (this.availibilityMonth < viewSelectedMonth) {
this.next(view, viewSelectedMonth);
}
else if (this.availibilityMonth > viewSelectedMonth) {
this.prev(view, viewSelectedMonth);
}
}
};
ngOnInit() {
//api-call
let fromDate ='2018-02-01'
let toDate = '2018-03-01'
this.getAvailibilty(fromDate, toDate);
}
//AJAX-CALL
getAvailibilty(fromDate, toDate, filters?) {
this._loader.showLoader();
this.calendarService.getAvailibilty(fromDate, toDate,
filters).subscribe((res: any) => {
this._loader.hideLoader();
const resBody = JSON.parse(res._body);
this.events = this.createEvents(resBody.data.availability);
this.bindEvents();
if (resBody.data.salutation && resBody.data.name) {
this.dentistOrPracticeName = resBody.data.salutation + ' ' +
resBody.data.name;
} else {
this.dentistOrPracticeName = resBody.data.name;
}
},
(err) => {
this._helper.errorHandling(err, this.vcr)
this._loader.hideLoader();
},
() => {
this._loader.hideLoader();
});
}
现在的问题是日历上没有显示事件。