首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AngularJS中未定义$scope.scheduler

AngularJS中未定义$scope.scheduler
EN

Stack Overflow用户
提问于 2015-07-21 05:42:35
回答 1查看 489关注 0票数 0

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

它工作得很好,但是当我想从一个外部服务器加载我的所有事件时,该服务器以json格式返回事件时,我遇到了问题。

view.html

代码语言:javascript
复制
<div ng-controller="ViewSchedulerDPCtrl" >
  <daypilot-scheduler id="scheduler" daypilot-config="schedulerConfig" daypilot-events="events" ></daypilot-scheduler>
</div>

schedulerDP.js

代码语言:javascript
复制
'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控制台日志时,它显示一个错误:

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

有人知道我做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2017-06-28 21:54:39

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31526864

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档