0

我正在使用Angularjs日曆UI創建事件調度程序日曆。最初隱藏日曆,並在開關切換時顯示。但日曆不會呈現,直到按下next或prev月份按鈕。使用ng-click從其他控制器渲染角度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 defineduiCalendarConfig not defined

回答

0

依賴聲明和注入必須是相同的和有序的。

不喜歡它:

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

我試過了。現在沒有錯誤,但它現在沒有觸發.. $ rootScope。$ emit和$ rootScope。$ on未觸發 – Manjunath

+0

我沒有在您的發佈代碼中看到任何'$ rootScope。$ emit' ..?, – anoop

+1

謝謝!它現在工作.. :)你提到的點工作.. – Manjunath