2017-09-26 79 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