I have been working with AngularJS v1.4.1 and DayPilot v8.1.17 making this tutorial.
It is working fine but I have problems when I want to load all my events from an external server that returns the events in json format.
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;
});
}
});
The scheduler loads the resources correctly but it doesn't display the events, when I see the Chrome Console Log it displays an error:
When I put a break point into the line that gives error it seems to be empty:
Does anyone know what I am doing wrong?