I am learning AngularJs. I have a simple controller:
angular.module('test').controller('RouteFinderController', function ($scope) {
$scope.startSystem = { systemName: "Test" }
});
this works as intended - the view can make use of the startSystem field.
However, if I make a slight change:
angular.module('test').controller('RouteFinderController', function ($scope) {
setTimeout(function() {
$scope.startSystem = { systemName: "Test" }
},0);
});
It no longer works! I can't access the startSystem field anymore.
Why is this, and how do I fix it?
$timeout(docs.angularjs.org/api/ng/service/$timeout) instead ofsetTimeout- otherwise Angular doesn't know the scope changed and that it needs to update the view