Which one handles exception automatically between $digest and $apply?



Which one handles exception automatically between $digest and $apply?..

Answer / swati maheshwari

$apply handle exceptions.
scope.$digest() will only fire watchers on current scope, scope.$apply will evaluate passed function and run $rootScope.$digest().

First one is faster, as needs to evaluate watchers for current scope, second one is slower (needs to evaluate watchers for$rootScope and all it's child scopes).

When error occurs in one of the watchers and you use scope.$digest, it's not handled via $exceptionHandler service, so you need to handle exception yourself. scope.$apply uses try catch block internally and passes all exceptions to $exceptionHandler.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More AngularJS Interview Questions

How install npm install?

1 Answers  


Mention some angularjs directives and their purpose?

1 Answers  


How to use multiple ng-app within a page in angularjs?

1 Answers  


Is angular front end?

1 Answers  


In which language, angularjs is written?

1 Answers  


What is template angular 2?

1 Answers  


Write ajax call syntax?

1 Answers  


Difference between constructor and ngoninit?

1 Answers  


How long will it take to learn react?

1 Answers  


Why is typescript used in angular?

1 Answers  


What is template reference variable in angular?

1 Answers  


What is cdk in angular?

1 Answers  


Categories