代码之家  ›  专栏  ›  技术社区  ›  MJN

使用ng单击从其他控制器渲染角度ui日历

  •  0
  • MJN  · 技术社区  · 7 年前

    我使用Angularjs日历UI创建事件调度程序日历。最初,日历是隐藏的,并在开关切换它显示。但直到按下“下一个月”或“上一个月”按钮,日历才会呈现。

    app.controller('toggleController', [ '$scope', function($scope) {
      $scope.toggleSelection = function toggleSelection(event) {
          angular.element(document.querySelectorAll('.calendar-container')).css({display:'block'});
      };
    }]);
    

    所以我想从日历ui控制器调用render函数,以便在从上面的控制器切换视图时进行渲染

    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 defined uiCalendarConfig not defined

    1 回复  |  直到 7 年前
        1
  •  0
  •   anoop    7 年前

    依赖项声明和注入必须是相同的,并且按顺序进行。

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