2014-01-27 40 views
3

我正在使用Angular-UI的日曆,我真的很喜歡。但是,我遇到了後期綁定的問題。Angular-UI-Calendar延遲綁定?

該指令是這樣的:

<div ui-calendar="uiConfig.calendar" ng-model="eventSources" calendar="myCalendar" class="cal-self panel panel-custom"> 

eventSources來自大量服務器端API請求。日曆已經呈現到頁面後,請求總是完成。

任何想法都可以延遲?

回答

2

我已經通過執行以下操作獲得了成功:我將在ui-calendar的repo上給出當前源文件的行號。之後調用getFullCalendarConfig做:〜行203 - 你需要注入$timeout

var viewChanged = false, 
    oldViewDisplay = fullCalendarConfig.viewDisplay || fullCalendarConfig.viewRender; 
delete fullCalendarConfig.viewDisplay; 
fullCalendarConfig.viewRender = function(view){ 
    if(oldViewDisplay)oldViewDisplay(view); 
    viewChanged = true; 
    $timeout(function(){viewChanged = false}); 
}; 

,然後傳遞到eventWatcher.subscribe(scope...函數裏面做的:〜行255

if (!viewChanged) 
    scope.calendar.fullCalendar('refetchEvents');   
if (sourcesChanged === true) { 
    // Rerender the whole thing if a new event source was added/removed 
    scope.calendar.fullCalendar('rerenderEvents'); 
    sourcesChanged = false; 
    // prevent incremental updates in this case 
    return false; 
} 

更新

所以我做了plunker。 它基本上有一個簡化的/破損的UI日曆指令(v0.1.2 | 3時代)。然而,可以說(恕我直言),該指令是'過度angularized'fullcalendar功能非常好,它自己的設備(這是很多和證明)。

+0

不幸的是,這並沒有奏效。 – claydiffrient

+0

我已經添加了一個plunker,我希望這個解決方案能幫上忙! – calebboyd