【问题标题】:Render angular ui calendar from other controller using ng-click使用 ng-click 从其他控制器渲染角度 ui 日历
【发布时间】:2017-07-26 04:09:52
【问题描述】:

我正在使用 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 或 uiCalendarConfig not defined 等

【问题讨论】:

    标签: angularjs fullcalendar fullcalendar-scheduler ui-calendar


    【解决方案1】:

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

    这样做:

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

    【讨论】:

    • 我试过了。现在没有错误,但现在没有触发.. $rootScope.$emit 和 $rootScope.$on 没有触发
    • 我在您发布的代码中没有看到任何$rootScope.$emit..?,
    • 很高兴帮助你:)
    猜你喜欢
    • 1970-01-01
    • 2015-09-21
    • 2011-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多