完整日历:如何在事件点击上更改事件标题



我正在使用全日历角度 2

export class Calender {
public value: any = 2;
public modalData: any[];
calendarOptions: any;
@ViewChild(CalendarComponent) myCalendar: CalendarComponent;
changeCalendarView(view) {
this.myCalendar.fullCalendar('changeView', view);
}

form: FormGroup;
constructor(private route: Router, private calenderservice: CalenderService, private appstate: AppState) {
}
ngOnInit() {
this.calendarOptions = {
height: '1000',
fixedWeekCount: false,
header:
{
left: 'prev,next,today',
center: 'title',
right: 'month,listYear',
},
defaultDate: '2017-01-01',
editable: true,
timeFormat: 'hh:mm A',
eventLimit: true,

events: (start, end, title, callback) => {
this.calenderservice.getExamCandidateById(this.value)
.subscribe(response => {
callback(response),
this.modalData = response.Items
this.myCalendar.fullCalendar('renderEvents', this.modalData)
console.log(this.modalData);
console.log(response);
});
},
eventClick: function (event, jsEvent, view) {   
alert('Your seat has been reserved on this date and time:' + event.start.format());
console.log(event); 
event.title = "clicked on"; 
this.myCalendar.fullCalendar('updateEvents', event)
localStorage.setItem('Events', JSON.stringify(event));          
},
dayClick: function(date, jsEvent, view) {
alert('Clicked on: ' + date.format());
}
};
}

在事件单击上,我将 event.title 更改为单击,在调试器中显示新更改的事件后,但日历不刷新或使用新更改的事件进行更新。

请帮助我,我是角度 2 的新手。

提前致谢

您必须使用箭头函数表示法() => {},不要使用function关键字,否则您的this上下文将更改为该函数:

eventClick: (event, jsEvent, view) => {   
event.title = "clicked on"; 
this.myCalendar.fullCalendar('updateEvents', event)
localStorage.setItem('Events', JSON.stringify(event));          
}

相关内容

  • 没有找到相关文章

最新更新