AngularJS UI-calendar not updating events on Calendar

前端 未结 11 2325
[愿得一人]
[愿得一人] 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条回答
  •  萌比男神i
    2020-12-10 05:04

    Here is how I fixed a similar problem on my page.

    view (simplified, note using jade)

    div#calendarNugget(ng-show="activeCalendar == 'Nugget'" ui-calendar="uiConfig.calendarNugget" ng-model="eventSources")
    div#calendarWillow(ng-show="activeCalendar == 'Willow'" ui-calendar="uiConfig.calendarWillow" ng-model="eventSources2")
    

    controller:

    As per ui-calendar docs, I start with an empty array for my event sources. Ignore that I should probably rename these eventSources to something about the shop names (willow, nugget)

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

    I then call a factory function that makes an http request and pulls a series of events from the DB. The events all have "title", "start", "end" properties (make sure your Date format is correct). They also have a "shop" property, which tells me which calendar to add the event to.

    So after receiving the data I make two local arrays, loop through the received http data, and assign the events to those local arrays by shop. Finally, I can re-render the calendars with the proper event data by calling addEventSource, which automatically re-renders as per the fullCalendar docs

    It looks something along the lines of this iirc:

    function splitShiftsByShop(shifts) {
    
      var nuggetShifts = [];
      var willowShifts = [];
    
      for (var i=0; i

提交回复
热议问题