使用 ng-click 从其他控制器渲染 angular ui 日历

Render angular ui calendar from other controller using ng-click

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

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

$timeout not defined or uiCalendarConfig not defined etc

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

这样做:

app.controller('CalendarCtrl', ['$scope','$compile', '$timeout', 'uiCalendarConfig`, function($scope,  $compile, $timeout, uiCalendarConfig) {\