我正在使用MattLewis引导日历。事件显示正确。但是如果我向日历中添加新事件,它将复制其他日期中的事件,而不是将事件添加到添加的日期中。
只有在刷新页面之后,一切才能正常工作
好的。我试了$scope。也试了$apply。但似乎没什么用。
这是我的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>
控制器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函数,事件在日历中也没有正确填充。如果我已经有了事件,那么在添加新事件之后,旧事件正在复制和显示。如果我重新加载页面,那么一切都很好。在HTML中,我在ng-in i t中调用MyEvents函数。有谁能告诉我o添加事件后不重新加载页面,是否正确显示事件?