在拖放事件之后,AngularJS UI日历不会更新$ scope.eventSources数据模型。 我需要获取更新的模型,但没有任何效果。
我尝试了很多事情,没有任何效果。
这是我的代码:
/* config object */
$scope.uiConfig = {
calendar:{
height: 600,
editable: true,
header:{
left: 'month basicWeek basicDay agendaWeek agendaDay',
center: 'title',
right: 'today prev,next'
},
eventClick: $scope.alertEventOnClick,
eventDrop: $scope.alertOnDrop,
eventResize: $scope.alertOnResize,
eventRender: function (event, element) {
if (event.HighPriority == 1) {
event.className ='highPriority';
}
}
}
};
/* load events source that contains custom events on the scope */
$scope.events = agendaFactoryLocalStorage.getAgenda();
$scope.eventSources = [$scope.events];
$scope.alertOnDrop = function(event, delta, revertFunc, jsEvent, ui, view){
$scope.alertMessage = ('Event Droped to make dayDelta ' + delta);
uiCalendarConfig.calendars.exampleCalendar.fullCalendar('removeEvents');
uiCalendarConfig.calendars.myCalendar.fullCalendar('refetchEvents');
});
$scope.save_agenda = function(){
agendaFactoryLocalStorage.updateAgenda($scope.eventSources);
}
$ scope.save_agenda仍然发送相同的数据模型,尽管我拖放了1个事件,但我真的不知道该怎么办,因为3个小时了。 $ scope.eventSources可以正确加载,但是拖放并不会改变模型,只有'event'变量被更新了,但是它是唯一的,我试图将其推入$ scope.eventSources里面没有运气
答案 0 :(得分:0)
好吧,我发现了一些可能会起作用的东西,它在拖动事件后现在正在正确更新$ scope.eventSources:
$scope.alertOnDrop = function(event, delta, revertFunc, jsEvent, ui, view){
$scope.alertMessage = ('Event Droped to make dayDelta ' + delta);
$scope.eventSources[0][1].start = event.start.format();
};
它使用拖动的日期值更新旧的日期值 我仍然每次都必须获得正确的索引。