0

我正在使用 Angularjs 日历 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');
        }
      });
    };
}]);

我尝试使用调用 renderCalendar 函数,$rootscope但出现以下错误

$timeout not defineduiCalendarConfig not defined

4

1 回答 1

0

依赖声明和注入必须相同且有序。

这样做:

app.controller('CalendarCtrl', ['$scope','$compile', '$timeout', 'uiCalendarConfig`, function($scope,  $compile, $timeout, uiCalendarConfig) {\\
于 2017-07-26T04:45:38.243 回答