angular-ui / ui-calendar

A complete AngularJS directive for the Arshaw FullCalendar.
http://angular-ui.github.io/ui-calendar/
MIT License
1.49k stars 728 forks source link

Problem with events added after initial load. #344

Closed martinlong1978 closed 8 years ago

martinlong1978 commented 8 years ago

This bug can be seen on the demo calendar hosted here: http://angular-ui.github.io/ui-calendar/ when using "/* event source that contains custom events on the scope */"

Events that are added to the array in the scope at the time the controller is constructed work fine, as expected. However, events that are added after this time (e.g. in response to an event or perhaps a promise such as a http load), will show, providing they are in view (current month). But as soon as they go out of view, they will disappear.

To reproduce, open up the demo page. Go forward and backward through the months, you will see that this works as expected.

Now, while on the current month, click "Add event" a few times. You'll see the events appear on the calendar as expected.

Finally, click back to last month, and then forward again. You'll see all of the original entries, however, the newly added ones have disappeared.

In my own application, I've worked around this by adding to the existing scope array but also returning a copy of that array in another function eventSource. So adding items to the scope array covers showing the items immediately after adding them, and the function handles redisplaying them after navigation.

This workaround is not ideal though.

martinlong1978 commented 8 years ago

Sorry, just spotted this:

Adding new events issue

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.