comiventor
comiventor

Reputation: 4122

Is it mandatory to use $scope.$apply for non-angular event

Is it a good practice to always update scope variable(s) using $scope.$apply when the control returns from a non-angular event?

I have a use case where same method is used by both angular and non-angular event and I want to avoid code duplication.

Upvotes: 0

Views: 65

Answers (1)

Rani Radcliff
Rani Radcliff

Reputation: 5084

You do need to use it if you are going to run code in a new turn. And only if that turn isn’t being created from a method in the AngularJS library. Inside that new turn, you should wrap your code in $scope.$apply(). Take a look at this link.

Upvotes: 1

Related Questions