Thanks very much, Sander!  Perfect explanation.  I very much appreciate 
your help, and I wish you well.

I'll take a look at the styleguide, per your suggestion.

Regards,
Scott

On Thursday, September 24, 2015 at 1:37:37 AM UTC-4, Sander Elias wrote:
>
> 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