AngularJS UI-calendar not updating events on Calendar

前端 未结 11 2353
[愿得一人]
[愿得一人] 2020-12-10 04:52

I am using Angular UI-Calendar to show some events on the Calendar. The events are showing fine on the Calendar. But when I update any event\'s details, the event\'s detail

11条回答
  •  难免孤独
    2020-12-10 05:22

    Although it's late response but hope it may help some. I am putting it forth step by step.

    1. You will need to maintain the same event source as Studio4Development mentioned earlier.

      $scope.events //no need to reinitialize it

    2. You will remove the updated event from events array like this (for last event in event array):

      $scope.events.splice($scope.events.length - 1, 1);

    For event that may exist anywhere in the events array you'll need to find its index using:

    var eventIndex = $scope.events.map(function (x) { return x.Id; }).indexOf(eventId);
    

    and then you'll remove it from events array like this:

    $scope.events.splice(eventIndex, 1);
    
    1. Next you'll fetch this event from the API again like this:

      getEvent(data.Id);

    2. and in the callback method you'll again add the event in events array:

      var getSingleEventSuccessCallback = function (event) { $scope.events.push(event); };

提交回复
热议问题