0
我有一個名爲CalendarDemoCtrl的控制器,其中我具有fullcalendar的配置,如下所示。angularjs fullcalendar eventclick範圍
$scope.uiConfig = {
calendar: {
height: 600,
editable: false,
locale:'es',
//navLinks: true, // can click day/week names to navigate views
businessHours: true, // display business hours
allDaySlot: false,
slotLabelFormat : 'h:mm a',
timeFormat: 'h:mm a',
navLinks: true,
navLinkDayClick: function(date, jsEvent) {
cc['mycalendar'].fullCalendar('changeView','agendaDay');
cc['mycalendar'].fullCalendar('gotoDate',date);
$scope.currentDate = cc['mycalendar'].fullCalendar("getView").title;
},
defaultView: 'agendaDay',
slotDuration: '00:15:00',
header: false, // remove default toolbar
//editable: true,
eventRender: $scope.eventRender,
eventClick : $scope.onEventClick
//dayClick : $scope.onEventClick
}
}
和我在同一個控制器中定義了$ scope.onEventClick和$ scope.addEvent。
$scope.addEvent = function() {
$rootScope.oldFormData = $.extend(true, {}, $scope.formData);
$scope.entroModal = true;
$scope.modalOpen('new');
};
$scope.onEventClick = function(index) {
$scope.formData = $.extend(true, {}, index.cita);
var date_inicio = new Date(index.cita.inicio) ;
$scope.formData.inicio = date_inicio.getDate() + "/" + (date_inicio.getMonth() + 1) + "/"+ date_inicio.getFullYear()+ " " + date_inicio.getHours()+ ":" + (date_inicio.getMinutes()<10?'0':'') + date_inicio.getMinutes();
var date_fin = new Date(index.cita.fin) ;
$scope.formData.fin = date_fin.getDate() + "/" + (date_fin.getMonth() + 1) + "/"+ date_fin.getFullYear()+ " " + date_fin.getHours()+ ":" + (date_fin.getMinutes()<10?'0':'') + date_fin.getMinutes();
$.extend($scope.formData , $rootScope.oldFormData);
$scope.modalOpen('edit');
};
第一個與用戶想要添加事件時使用按鈕,第二個是在日曆中編輯事件。然而,當添加一個事件時,範圍將進入一個低於eventclick的範圍,因此當我添加事件時,它顯示在日曆中,當我點擊並編輯事件時,事件在日曆中未被修改,因爲它是上述範圍。
$ rootscope:id爲1
$範圍:ID是10(這是eventclick作品)
小孩$範圍:ID 11(這是的addEvent作品)
這是完全混亂,我很困惑這是怎麼發生的,我怎麼能在同一範圍內的兩個事件?請指教,謝謝!