我一直在使用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控制台日志时,它显示一个错误:

当我在给出错误的行中放一个断点时,它似乎是空的:

有人知道我做错了什么吗?
发布于 2017-06-28 21:54:39
当我在ionic应用中使用时,我也遇到了这个问题,我发现$scope.scheduler在$scope.$$childHead.$$childHead.scheduler中
https://stackoverflow.com/questions/31526864
复制相似问题