Angular bootstrap 添加或更新事件后日历不更新视图

Angular bootstrap calendar doesnt update view after adding or updating events

我正在使用 mattlewis bootstrap calendar.Events 正在显示 correctly.But 如果我向日历添加新事件,它会复制其他日期的事件,而不是将事件添加到添加的日期。仅在刷新页面后一切正常 fine.I 尝试了 $scope.$apply also.But 似乎没有任何效果。

这是我的html

<mwl-calendar events="events" view="calendarView" 
    view-date="viewDate" view-title="calendarTitle"
    on-event-click="eventClicked(calendarEvent)"
    on-event-times-changed="eventTimesChanged(calendarEvent);
    calendarEvent.startsAt = calendarNewEventStart; calendarEvent.endsAt = calendarNewEventEnd"
    cell-is-open="cellIsOpen" day-view-start="06:00"
    day-view-end="22:59" day-view-split="30"
    cell-modifier="cellModifier(calendarCell)"
    on-event-click="eventClicked(calendarEvent)"
    cell-auto-open-disabled="true"
    on-timespan-click="timespanClicked(calendarDate, calendarCell)">
</mwl-calendar>

Controller.js

$scope.events = [];
$scope.myevents = function(start, end, timezone, callback) {
    SalesNotifyService.getAllNotify().then(function(response) {
        $scope.allleadnotify  = response.data;
        console.log($scope.allleadnotify);
        var events = [];
        angular.forEach($scope.allleadnotify,function(event,key){
            var today = new Date();
            var notifyDates = new Date(event.notifyDate);
            if(event.leadName!=null){
                $scope.events.push({
                    title: event.notifyType,
                    startsAt : event.notifyDate,
                    endsAt : event.notifyEndDate,
                    withoffender: event.leadName,
                });
            } else {
                $scope.events.push({
                    title: event.notifyType,
                    startsAt : event.notifyDate,
                    endsAt : event.notifyEndDate,
                    withoffender: '',
                });
            }
        });
    });
}

现在保存后我正在调用 $scope.myevents 函数,就像这样

SalesNotifyService.saveNotify(notify).then(function(response){
    $scope.notify = response.data;
    $scope.myevents();
});

但即使我调用 myevents 函数事件也没有填充到日历中 properly.If 我已经有事件然后在添加新事件后旧事件正在复制并且 displaying.If 我重新加载页面然后一切都是fine.In html 我在 ng-init.Can 中调用 myevents 函数 谁能告诉我如何在添加事件后正确显示事件而不重新加载页面?

也许您需要在再次添加事件之前将 $scope.events 重置为空数组?如果您不这样做,那么每次调用 $scope.myevents() 时,您都会在同一数组中再次添加事件而不删除它们。所以在 $scope.myevents 函数的开头做 $scope.events=[]

$scope.events = 事件;并将事件推送到本地 "events" 数组。