2017-09-26 281 views
0

我在控制器事件數組聲明的事件,每文檔UI日曆不工作,不渲染

eventSources: [ 
     { 
      events: [ 
       { title: 'event1', start: '2017-09-27' }, 
       { title: 'event2', start: '2017-09-27', end: '2017-09-27' }, 
       { title: 'event3', start: '2017-09-27T12:30:00', } 
      ] 
     } 
    ] 

我加入NG-模型日曆組件定義(VM爲控制器的一個別名) 。

取而代之的是日曆,填充了這些事件,我看到,不要告訴我什麼錯誤消息的空白日曆和噸。哪裏不對?

enter image description here

enter image description here

有人要求把完整的代碼,不知道這是怎麼回事幫助,但在這裏它是,calendar.component.ts:

namespace AppDomain { 

    class CalendarComponent { 
     public bindings: any; 
     public controller: any; 
     public controllerAs: string; 
     public templateUrl: string; 

     constructor() { 
      this.controller = CalendarController; 
      this.controllerAs = 'vm'; 
      this.templateUrl = '/app/calendar/calendar.component.html'; 
     } 
    } 

    class CalendarController { 
     eventSources: [ 
      { 
       events: [ 
        { title: 'event1', start: '2017-09-27' }, 
        { title: 'event2', start: '2017-09-27', end: '2017-09-27' }, 
        { title: 'event3', start: '2017-09-27T12:30:00', } 
       ] 
      } 
     ] 

     constructor() { } 

     $onInit() { } 
    } 

    angular.module('app').component('calendarComponent', new CalendarComponent()); 
} 

而且calendar.component.html:

<div ui-calendar ng-model="vm.eventSources"></div> 

希望這有助於

UPDATE

即使我添加UI日曆這樣的,沒有任何NG-模型事件,

<div ui-calendar></div> 

只是一個空白日曆,我仍然得到所有這些錯誤

UPDATE2

我TRIE d此過程中,以及:

events2: [ 
     { title: 'event1', start: '2017-09-27' }, 
     { title: 'event2', start: '2017-09-27', end: '2017-09-27' }, 
     { title: 'event3', start: '2017-09-27T12:30:00', } 
    ] 

然後

同樣的問題

+1

您可以添加更多的代碼? – bazzells

+0

你認爲它會幫助你嗎? – monstro

+0

在這裏,添加了代碼! – monstro

回答

0

不能使用空ui-calendar酸當量<div ui-calendar></div>

應該由ng-model

<div ng-model="events" ui-calendar="options"></div> 

其中events是事件和選項的列表(可選)配置 - 日曆配置


所以你的問題是在事件結構

eventSources應該是數組陣列

例如:

[ 
    [ 
    { 
     "title": "Long Event", 
     "start": "2017-09-27", 
     "end": "2017-09-27" 
    } 
    ] 
] 

Demo Fiddle

+0

謝謝,這工作! – monstro