我正在使用Angularjs Calendar UI来创建事件调度程序日历。最初日历是隐藏的,并在切换时显示它。但是日历直到按下下一个或上个月按钮才会呈现。
app.controller('toggleController', [ '$scope', function($scope) {
$scope.toggleSelection = function toggleSelection(event) {
angular.element(document.querySelectorAll('.calendar-container')).css({display:'block'});
};
}]);
所以我想从日历 UI 控制器调用渲染函数,以便在从上面的控制器切换视图上呈现它
app.controller('CalendarCtrl', ['$scope','$rootScope', function($scope, $compile, $timeout, uiCalendarConfig) {
/* Change View */
$scope.renderCalendar = function(calendar) {
$timeout(function() {
if(uiCalendarConfig.calendars[calendar]){
uiCalendarConfig.calendars[calendar].fullCalendar('render');
}
});
};
}]);
我尝试使用$rootscope
调用 renderCalendar 函数,但出现以下错误
$timeout not defined
或uiCalendarConfig not defined
等
依赖声明和注入必须相同且有序。
这样做是这样的:
app.controller('CalendarCtrl', ['$scope','$compile', '$timeout', 'uiCalendarConfig`, function($scope, $compile, $timeout, uiCalendarConfig) {\