mattlewis92/angular-bootstrap-calendar

how to call custom service on click of events and fetch the calendar data through that custom service

SheethalRamesh opened this issue · 7 comments

how to call custom service on click of events and fetch the calendar data through that custom service

Use on-event-click="vm.eventClicked(calendarEvent)" as shown here and in your controller assign service (or service method) to vm.eventClicked, i.e.: vm.eventClicked = myService.eventClicked;. The method must accept one parameter, which would be the clicked event.

Is this the answer you needed or do you need something else?

How to bind the data from the backend to calendar event in such a way that it should display data on event itself?

I don't understand what you want to achieve. You want to be able to modify the clicked event from the service and return it to the calendar? If so:

Yes that is what i need. On click of an event, a dialog box should open and whatever data entered inside dialog box should be binded on the calendar event.

The event argument has calendarEventId field which is the event's index in vm.events. It's enough to call the service method with two arguments to be able to modify clicked event service-side:

vm.eventClicked = function(event) {
    vm.events = myService.eventClicked(event, vm.events);
}

Or:

vm.eventClicked = function(event) {
    vm.events[event.calendarEventId] = myService.eventClicked(vm.events[event.calendarEventId]);
}

Will work on it.. Thanks a lot!!!!

No problem. Should you need more help just post again in this thread, there is no need to open new one :)