0

我一直在使用 AngularJS v1.4.1 和 DayPilot v8.1.17 制作本教程

它工作正常,但是当我想从以 json 格式返回事件的外部服务器加载所有事件时遇到问题。

视图.html

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

调度程序DP.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 控制台日志时,它显示错误:

在此处输入图像描述

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

在此处输入图像描述

有谁知道我做错了什么?

4

1 回答 1

0

我在 ionic 应用程序中使用时也遇到了这个问题,我发现 $scope.scheduler 在 $scope.$$childHead.$$childHead.scheduler

于 2017-06-28T13:54:38.833 回答