2016-07-26 33 views
0

UI工作正常,事件顯示正確,但唯一的問題是eventClick不起作用。我認爲jQuery需要更新來解決這個問題,但我錯了。還有一件事是阻止eventClick工作!請幫助eventClick在angular-ui-日曆不工作

這是我的index.html

<div class="container"> 
 
<div ui-calendar='$ctrl.uiConfig.calendar' ng-model="$ctrl.eventSources"> 
 
</div> 
 
</div>

這是我controller.js

(function(){ 
 

 
class CalendarComponent { 
 
    constructor() { 
 

 
    this.eventSources = []; 
 

 
    this.uiConfig = { 
 
     calendar : { 
 
       editable : true, 
 
       header : { 
 
         left : 'prev,next,today', 
 
         center : 'title', 
 
         right : 'month,agendaWeek,agendaDay' 
 
         } 
 
        }, 
 

 
      eventClick: function(event,jsEvent,view){ 
 
         console.log("holla"); 
 
         } 
 
       }; 
 

 
    
 

 
    this.eventSources = [ 
 

 
      { 
 
      events: [ 
 
        {title: "finger painting", start: "2016-07-28T18:00+05:30", location: "SAC middle earth", allDay:false}, 
 
        {title: "hand painting", start: "2016-07-27T21:30+05:30",location: "CLT", allDay:false} 
 
       ], 
 

 
      color: "red" 
 
      }, 
 

 
     { 
 
      events: [ 
 
        {title: "lightmusic", start: "2016-07-29T18:00+05:30", location: "OAT", allDay:false}, 
 
        {title: "Rock music", start: "2016-07-28T21:30+05:30",location: "SAC middle earth", allDay:false} 
 

 
       ], 
 

 
       color: "blue" 
 
      } 
 

 
    ];    
 
     
 
       
 
    } 
 

 
} 
 

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

 
})();

+1

您只將日曆傳遞給UI日曆,但未傳遞整個配置對象。我不知道這個特定的指令應該如何工作,但不應該傳遞所有'$ ctrl.uiConfig'? – Jay

+0

工作......實際上我刪除了日曆,並將所有內容都整合到了uiConfig中,並將它傳遞給了ui-calendar .....感謝隊友! – Robin

+0

沒問題!我只是將它作爲一個答案發布,只是爲了避免其他人碰巧遇到同樣的問題 – Jay

回答

1

嘗試傳遞uiConfig反對ui-calendar,現在eventClick不在您傳遞給該指令的對象內