mattlewis92 / angular-bootstrap-calendar

A port of the bootstrap calendar widget to AngularJS (no jQuery required!)
https://mattlewis92.github.io/angular-bootstrap-calendar/
MIT License
798 stars 369 forks source link

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

Closed SheethalRamesh closed 7 years ago

burtek commented 7 years ago

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?

SheethalRamesh commented 7 years ago

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

burtek commented 7 years ago

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:

SheethalRamesh commented 7 years ago

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.

burtek commented 7 years ago

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]);
}
SheethalRamesh commented 7 years ago

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

burtek commented 7 years ago

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