import { OnInit } from '@angular/core';
import { HelpersService } from 'src/app/helpers.service';
@Component({
selector: 'app-system-maintenance',
templateUrl: './system-maintenance.page.html',
styleUrls: ['./system-maintenance.page.scss'],
})
export class SystemMaintenancePage implements OnInit {
constructor(
public helpers : HelpersService,
) {}
calendarVisible = false;
calendarOptions: CalendarOptions = {
headerToolbar: {
center: 'prev,today,next',
left: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay',
},
initialView: 'dayGridMonth',
// initialEvents: INITIAL_EVENTS,
weekends: true,
editable: true,
nextDayThreshold: '00:00:00',
events: [
{
// Goes from 8pm to 10am the next day.
title: 'Event 2',
start: '2020-12-04T00:00:00',
end: '2020-12-06T00:00:01',
allDay : true,
html : true,
}
],
eventDidMount: function(info) {
/// console.log(info);
},
eventDrop: function(info) {
/// alert(info.event.title + " was dropped on " + info.event.start.toISOString() + ' to '+ info.event.end.toISOString());
if (!confirm("Are you sure about this change?")) {
info.revert();
}else{
this.helpers.update_sched(info.event);
}
},
selectable: true,
displayEventTime : true,
selectMirror: true,
// dayMaxEvents: true,
};
I'm facing an issue where I can't access my helper service function inside the eventDrop method. It shows as undefined when trying to update the schedule after dropping the event onto a specific date. The error message reads, "ERROR TypeError: Cannot read property 'helpers' of undefined".
Update: added additional lines of code to clarify my question.