I've integrated a custom button into my fullcalendar
:
ngOnInit() {
this.calendarOptions = {
customButtons: {
custom1: {
text: 'Add event',
click() {
this.openModal();
}
}
},
height: 600,
editable: true,
eventLimit: false,
locale: 'lt',
header: {
left: 'prev,next today, custom1,custom2',
center: 'title',
right: 'month,agendaWeek,agendaDay,listMonth'
},
events: ''
};}
When the button is clicked, I intend to execute the following function:
openModal() {
console.log('opened');
// '<app-add-event></app-add-event>';}
However, an error occurs stating
zone.js:199 Uncaught TypeError: this.openModal is not a function
at HTMLButtonElement.click (events-calendar.component.ts:20)
I'm unsure why this error is happening. How should I properly call a custom function?
I've also attempted:
this.calendarOptions = {
customButtons: {
custom1: {
text: 'Pridėti įvykį',
click:
this.openModal
}
}, ... };
In this scenario, console.log();
does work, but I still encounter an error afterwards. What could be the issue here?
Do I need to declare this function somewhere else in the code?
<ng-fullcalendar #ucCalendar [options]="calendarOptions" (eventClick)="eventClick($event.detail)" (eventDrop)="updateEvent($event.detail)"
(eventResize)="updateEvent($event.detail)" (clickButton)="clickButton($event.detail)"></ng-fullcalendar>