0

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:

enter image description here

When I put a break point into the line that gives error it seems to be empty:

enter image description here

Does anyone know what I am doing wrong?

Joan Gerard
  • 135
  • 6
  • 17

1 Answers1

0

I got this problem too when use in ionic app and put in I found that $scope.scheduler is in $scope.$$childHead.$$childHead.scheduler