weixin_39927508
weixin_39927508
2020-11-28 20:41

Update the calendar events on $scope.events changes

Hello everyone, I have been searching a way to solve this issue on Google and looks like other people have the same issue but solutions did not work for me.

I have a div :

and a dropdown that is changing the $scope.events.

1) I load some events on the calendar // Intialize scope values $scope.events = []; scope.eventSources = [$scope.events]; // Fetch events $http.get(appConfig.appUrl + '/event').then(function(events){ angular.forEach(events,function(event){ $scope.events.push(event); }); });

=> Events are well displayed (no error at moment)

2) When I select an item in the dropdown, it's doing an AJAX call on my server to fetch the according events.

Code example:


        // Function fired on Change selectbox
        $scope.changeTeam = function () {

            $scope.events = []; // Initialize back the event array since we gonna fetch new events


            /** Get all Events of the selected Team (Class) **/
            $http
                .get(appConfig.appUrl + '/event?where={"team":"' + $scope.teamSelected.id + '"}')
                .success(function (data) {
                    angular.forEach(data,function(event){
                         $scope.events.push(event);
                    });
                })
                .error(function (data) {
                    logger.logError('Erreur lors de la récupération des évènements.')
                })

        };  

=> Events are fetched correctly and dates are in the correct format => Problem: it's just not updating the Calendar view when I fetch my new events using the 2) ajax call.

Does anyone have a sample code ? Best regards,

该提问来源于开源项目:angular-ui/ui-calendar

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答

为你推荐

换一换