2015-07-20 90 views
0

我一直在使用AngularJS v1.4.1和DayPilot v8.1.17製作this tutorial

它工作正常,但我有問題,當我想從外部服務器加載所有我的事件以json格式返回事件。

view.html

<div ng-controller="ViewSchedulerDPCtrl" > 
    <daypilot-scheduler id="scheduler" daypilot-config="schedulerConfig" daypilot-events="events" ></daypilot-scheduler> 
</div> 

schedulerDP.js

'use strict'; 

    var app = angular.module('ModuleApp') 
    app.controller('ViewSchedulerDPCtrl', function($scope, $timeout, aircraftService,flightService) { 
     $scope.schedulerConfig = { 
      scale: "Hour", 
      days: 5, 
      startDate: new Date(), 
      timeHeaders: [ 
       { groupBy: "Month"}, 
       { groupBy: "Day", format: "d" }, 
       { groupBy: "Hour", format: "hh:mm" } 
      ] 
     }; 

     $timeout(function() { 
      loadResources(); 
      loadEvents($scope.scheduler.visibleStart(), $scope.scheduler.visibleEnd()); // this line doesn't work, scheduler got undefined 
     }); 

     var loadResources=function() { 

      aircraftService.getAllAircrafts().then(function(aircrafts){ 
      $scope.schedulerConfig.resources = aircrafts; 

      }); 
     } 

     function loadEvents(from, to) { 
      flightService.getFlights(from,to).then(function(flights){ 
      $scope.schedulerConfig.startDate = from; 
       $scope.schedulerConfig.days = Math.floor(new DayPilot.TimeSpan(to.getTime() - from.getTime()).totalDays()); 
       $scope.events = flights; 
      }); 
     } 
     }); 

調度正確地加載資源,但它並沒有顯示的事件,當我看到Chrome控制檯登錄它會顯示錯誤:

enter image description here

當我把一個破POIN牛逼到,讓錯誤時行似乎是空的:

enter image description here

有誰知道我做錯了嗎?

+0

你應該訪問schedulerConfig ??? – Fals

+0

$ scope.scheduler從來沒有定義....應該是?沒有用在任何地方 – charlietfl

+0

您是否在您的代碼的任何地方設置了$ scope.scheduler?像這樣: var scheduler = new DayPilot.Scheduler(「dps」); $ scope.scheduler = scheduler; –

回答

0

我有這個問題太當離子應用程序的使用和投入 我發現,$ scope.scheduler在$範圍。$$ childHead。$$ childHead.scheduler