search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

$scope.scheduler is undefined

Asked by Anonymous
5 years ago.


I am making this tutorial:

I can display the scheduler and load the resources from an external server that returns json values by other way I can't load events to the scheduler, the $scope.scheduler variable appears to be undefined when I debug it using Chrome dev. console. Here is some of my code:


$timeout(function() {
loadEvents($scope.scheduler.visibleStart(), $scope.scheduler.visibleEnd()); // here it says scheduler is undefined


<div ng-app="MyApp" ng-controller="Ctrl" >

  • scheduler id="scheduler" daypilot-config="schedulerConfig" daypilot-events="events" ></daypilot-scheduler>
  • </div>

Let me know what could be my error, maybe the scheduler view is not complete before my script is executed, it's driving me crazy.

Comment posted by Dan Letecky [DayPilot]
5 years ago.

The $timeout() wrapper should ensure that the scheduler is initialized before the loadResources() and loadEvents() methods are called. At that point, the object should be already stored in $scope.scheduler.

Can you try this minimum working example:

<!DOCTYPE html>
    <meta charset="UTF-8">
    <script src=""></script>
    <script src=""></script>
    <title>AngularJS Scheduler</title>

<div ng-app="main" ng-controller="DemoCtrl" >
    <daypilot-scheduler id="scheduler" daypilot-config="schedulerConfig" ></daypilot-scheduler>

    var app = angular.module('main', ['daypilot']).controller('DemoCtrl', function($scope, $timeout, $http) {
        $scope.schedulerConfig = {
            scale: "Day"

        $timeout(function() {
Comment posted by Anonymous
5 years ago.

That works perfectly, it displays $scope.scheduler in Chrome console log.

Answer posted by Dan Letecky [DayPilot]
5 years ago.

Then you should be able to start with this code and extend it step-by-step until you have all you need or until it stops working.

If it stops working please check the last thing you added.

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.