I'm trying to implement the loading callback function using the angular-ui calendar. I want my calendar to go to a specific date once it is loaded instead of going to the current date.
我正在尝试使用angular-ui日历实现加载回调函数。我希望我的日历在加载后转到特定日期,而不是转到当前日期。
I can get this functionality using the dayClick method, however I have not been able to implement the loading function using angular at all. Below is the code, note that the loading callback is not console logging anything.
我可以使用dayClick方法获得此功能,但是我还没有能够使用angular实现加载功能。下面是代码,请注意加载回调不是控制台记录任何东西。
$scope.goToRootScopeDate = function() {
$scope.myCalendar.fullCalendar('gotoDate', $rootScope.day);
}
/* config calendar view */
$scope.uiConfig = {
calendar: {
defaultView: "agendaDay",
// editable: true,
header: {
left: 'agendaWeek',
center: 'title',
right: 'today prev,next',
},
dayClick: $scope.goToRootScopeDate,
loading: function(bool) {
if (bool) {
console.log('Done loading')
} else {
console.log("still loading")
}
}
},
};
1 个解决方案
#1
5
If you want to manage the Loading callback method from the ng-controller...
如果要从ng-controller管理Loading回调方法...
Loading callback receives two parameters, not a boolean.
加载回调接收两个参数,而不是布尔值。
/* config calendar view */
$scope.uiConfig = {
calendar: {
defaultView: "agendaDay",
// editable: true,
header: {
left: 'agendaWeek',
center: 'title',
right: 'today prev,next',
},
dayClick: $scope.goToRootScopeDate,
loading: $scope.loading
},
};
And then you manage it in the controller with those 2 parameters
然后使用这两个参数在控制器中管理它
$scope.loading = function(isLoading, view){
alert("is loading" + isLoading);
}
You can reproduce it at this plunker where I added some annoying alerts to manage the loading callback.
你可以在这个plunker上重现它,我添加了一些恼人的警报来管理加载回调。
But, if you only want to load a specific date at the first screen... Just set the defaultdate in the config:
但是,如果您只想在第一个屏幕上加载特定日期...只需在配置中设置defaultdate:
/* config calendar view */
$scope.uiConfig = {
calendar: {
defaultView: "agendaDay",
// editable: true,
header: {
left: 'agendaWeek',
center: 'title',
right: 'today prev,next',
},
dayClick: $scope.goToRootScopeDate,
defaultDate:$scope.myDesiredDate
},
};
#1
5
If you want to manage the Loading callback method from the ng-controller...
如果要从ng-controller管理Loading回调方法...
Loading callback receives two parameters, not a boolean.
加载回调接收两个参数,而不是布尔值。
/* config calendar view */
$scope.uiConfig = {
calendar: {
defaultView: "agendaDay",
// editable: true,
header: {
left: 'agendaWeek',
center: 'title',
right: 'today prev,next',
},
dayClick: $scope.goToRootScopeDate,
loading: $scope.loading
},
};
And then you manage it in the controller with those 2 parameters
然后使用这两个参数在控制器中管理它
$scope.loading = function(isLoading, view){
alert("is loading" + isLoading);
}
You can reproduce it at this plunker where I added some annoying alerts to manage the loading callback.
你可以在这个plunker上重现它,我添加了一些恼人的警报来管理加载回调。
But, if you only want to load a specific date at the first screen... Just set the defaultdate in the config:
但是,如果您只想在第一个屏幕上加载特定日期...只需在配置中设置defaultdate:
/* config calendar view */
$scope.uiConfig = {
calendar: {
defaultView: "agendaDay",
// editable: true,
header: {
left: 'agendaWeek',
center: 'title',
right: 'today prev,next',
},
dayClick: $scope.goToRootScopeDate,
defaultDate:$scope.myDesiredDate
},
};