user985409
user985409

Reputation: 1385

scope.$apply without firing scope.$watch

Is it possible in AngularJS to do a scope.$apply without firing scope.$watch? How can this be achieved? I want to update a model but not fire $watch at a specific case.

Upvotes: 0

Views: 94

Answers (1)

Wawy
Wawy

Reputation: 6269

No, it's not. When you call apply it will create a new digest loop that will go through all the watchers registered through the app. And updating the model is basically triggering a watch.

Maybe you can catch that update in your $watch or do something clever with it like de-register when you call $apply and then registering it again.

Maybe it's worth if you post what you are trying to achieve.

PS: if you want to call $apply the safest way to do it is surround whatever code you want to be evaluated with $evalAsync.

Upvotes: 1

Related Questions