2016-06-25 27 views
0

我想在我的網頁上顯示日曆,不要把['ui.calendar']放在angular.module()中,但是在這種情況下,日曆並沒有顯示出來,如果我將它添加到angular.module()中,它就會顯示上述錯誤。請幫幫我 !

這些都是我的兩個JavaScript文件

'use strict'; 
 

 
angular.module('sangamApp') 
 
    .config(['$stateProvider',function ($stateProvider) { 
 
    $stateProvider 
 
     .state('calendar', { 
 
     url: '/calendar', 
 
     template: '<calendar></calendar>' 
 
     }); 
 
    }]);

'use strict'; 
 
(function(){ 
 

 
class CalendarComponent { 
 
    constructor() { 
 
    this.eventSources = []; 
 
    
 
    this.uiConfig = { 
 
     calendar : { 
 
       editable : true, 
 
       header : { 
 
         left : 'prev,next,today', 
 
         centre : 'title', 
 
         right : 'month,agendaWeek,agendaDay' 
 
         } 
 
        } 
 
       } 
 
    } 
 
} 
 

 
angular.module('sangamApp',['ui.calendar']) 
 
    .component('calendar', { 
 
    templateUrl: 'app/calendar/calendar.html', 
 
    controller: CalendarComponent 
 
    }); 
 

 
})();

回答

0

您使用$stateProvider但你忘了把你的模塊依賴ui.router

angular.module('sangamApp',['ui.calendar', 'ui.router']) // added ui.router 
+0

,但它工作正常,當我沒有把「ui.calendar」以及「ui.router」 ......其甚至沒有工作,如果我加上「ui.router」 – Robin

+0

真奇怪。第一個JavaScript文件是您主要的js文件嗎?還有哪個文件首先被加載? –

0

首次聲明你需要通過所有的模塊依賴關係的第二個參數列表angular.module因爲你正在使用$stateProvider你應該依賴條件

的列表中指定 ui.router應用模塊
angular.module('sangamApp',['ui.calendar', 'ui.router']) 
相關問題