If you skip the $apply, the angular will not know anything about your update, so it won't trigger the digest cycle. It's kind of advanced topic. You can read about it in official developer's guide.
Regards, Witold Szczerba --- Sent from my mobile phone. On Jun 1, 2014 9:25 PM, "marko" <[email protected]> wrote: > Hi, > > I'm building an app with Angular v1.2 where I need to update the model > from code running outside Angular. > Another framework that I'm using delivers events and the Angular model > needs to be updated in these event handlers. > After some trial and error, I managed to figure out a way to update the > model outside Angular like this: > > angular.element(document.getElementById("myElem1")).scope().$apply(function(scope) > { > scope.myModelProperty = "foo"; > }); > > > This appears to be working, but being a bit of a novice with Angular, I'd > like to know if this is a correct way to update the model from outside > Angular? > Is there a better way of doing it? > > marko > > -- > 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. > -- 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.
