angular-ui / ui-calendar

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

Issues with $scope.events #431

Closed zflopez closed 7 years ago

zflopez commented 7 years ago

Hi everyone!

I'm working with a JSON file to extract objects with dates to put them on a calendar, but there's some issue with those objects I'm pushing to $scope.events array. Because of this, every time I change to the next the month view, there's no events on the calendar at all, and if I return to the previous month, it's all gone.

` $scope.events = [];

$http.get("json/map_data.json").success(function(data) {
    $scope.locations = data;

    data.forEach(function(object) {
        if(object.hasOwnProperty("events")) {
            object.events.forEach(function(item) {
                $scope.events.push(item);
            })
        }
    })  
});`

$scope.eventSources = [$scope.events];

Thank you so much in advance!

peterver commented 7 years ago

hmm that's some strange behavior, have you tried taking a look at using eventSources ? http://fullcalendar.io/docs/event_data/Event_Source_Object/

contractus commented 7 years ago

i have the same problem! i think that there need use http://fullcalendar.io/docs/event_data/events_json_feed/#options sending URL of json and load all time the events

url: '/myfeed.php',

zflopez commented 7 years ago

Sorry for the delay! I think I solved the problem by putting eventSources inside $http call to my JSON! Like this:

$scope.events = [];

$http.get("json/map_data.json").success(function(data) { $scope.locations = data; $scope.events.splice(0);

data.forEach(function(object) {
    if(object.hasOwnProperty("events")) {
        object.events.forEach(function(item) {
            $scope.events.push(item);
        })
    }
})
/* event sources array*/    
$scope.eventSources = [$scope.events];

});

Thank you very much for commenting!

peterver commented 7 years ago

glad you managed to fix this yourself ^.^, and thanks for leaving a comment on how you did it :].