Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This line of code <code>$scope.calConfig = { ... }</code> runs before the Restangular call does.</p> <p>You need to set the config once the Restangular call completes.</p> <pre><code>Restangular.all('events').getList().then(function(event) { $scope.events = event; $scope.calConfig = { views: [ {"type": "agenda", "label": "Agenda"}, {"type": "agendaDay", "label": "Day"}, {"type": "agendaWeek", "label": "Week"}, {"type": "month", "label": "Month"}, ], view: "agendaWeek", eventSources: [$scope.events], now: moment().toDate(), /*/Callback Methods */ }; }); </code></pre> <p>This is because the Restangular code is asynchronous. You're basically asking it to execute something and <code>then</code> call a function once it's completed. </p> <p>For more information on this, look at <a href="http://docs.angularjs.org/api/ng" rel="nofollow">http://docs.angularjs.org/api/ng</a>.$q</p> <hr> <p><strong>Update:</strong> This moves your config code into it's own function and calls it once the request returns a positive response. You should probably handle a negative response.</p> <pre><code>Restangular.all('events').getList().then(function(event) { $scope.events = event; $scope.config(); }); $scope.config = function() { $scope.calConfig = { views: [ {"type": "agenda", "label": "Agenda"}, {"type": "agendaDay", "label": "Day"}, {"type": "agendaWeek", "label": "Week"}, {"type": "month", "label": "Month"}, ], view: "agendaWeek", eventSources: [$scope.events], now: moment().toDate() }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload