Hi Scott,

You should know about the $digest cycle. Whatever is done 'inside' angular 
will be picked up automatically. However, if something changes that angular 
does not know about (a setTimeout, or an native event) angular will only 
'see' this change the next time it does it's dirty checking. That's called 
the $digest cycle. 
You sample works if you use a $q promise, because it starts up the cycle. 
It does not work, in the setTimeout, because angular does not know (yet) 
that anything has changed. If you need to do something 'outside' you can 
tell angular to update by issuing an $scope.$apply()

For your sample I would change it like this:
 
$timeout(function() {
   globalData.push("fourth");
}, 2000);

That will work, as will this:
setTimeout(function() {
    globalData.push("fourth");
    $scope.$apply();
}, 2000);

So, does that answer your question enough?

Regards
Sander
(PS, if you are new, I encourage you to read the styleguide 
<https://github.com/johnpapa/angular-styleguide>!)

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to