The ui-calendar directive plays nicely with ng-model.
An Event Sources objects needs to be created to pass into ng-model. This object's values will be watched for changes. If a change occurs, then that specific calendar will call the appropriate fullCalendar method.
The ui-calendar directive expects the eventSources object to be any type allowed in the documentation for the fullcalendar. docs Note that all calendar options which are functions that are passed into the calendar are wrapped in an apply automatically.
Accessing the calendar object
It is possible to access a specific calendar object by declaring a name for it on the uiCalendar directive. In this next line we are naming the calendar 'myCalendar'. This will be attached to the uiCalendarConfig constant object, that can be accessed via DI.
Now the calendar object is available in uiCalendarConfig.calendars:
uiCalendarConfig.calendars.myCalendar
This allows you to declare any number of calendar objects with distinct names.
Custom event rendering
You can use fullcalendar's eventRender option to customize how events are rendered in the calendar.
However, only certain event attributes are watched for changes (they are id, title, url, start, end, allDay, and className).
If you need to automatically re-render other event data, you can use calendar-watch-event.
calendar-watch-event expression must return a function that is passed event as argument and returns a string or a number, for example:
When adding new events to the calendar they can disappear when switching months. To solve this add stick: true to the event object being added to the scope.
Watching the displayed date range of the calendar
There is no mechanism to $watch the displayed date range on the calendar due to the JQuery nature of fullCalendar. If you want
to track the dates displayed on the calendar so you can fetch events outside the scope of fullCalendar (Say from a caching store
in a service, instead of letting fullCalendar pull them via AJAX), you can add the viewRender callback to the calendar config.