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 |
Can you explain spa architecture in angularjs?
What is a component in angular 2?
What is difference between ng if and ng show?
Explain what is injector in angularjs?
How can you handle errors in angular 2 applications?
How http client is interact with angular 2 servers?
Explain what the link function is and how it differs from compile?
What is the possible order of lifecycle hooks in angular?
What are pipes in angular 2?
What is pathmatch in angular?
What is angular 2 and typescript?
How to disable a control or element in angularjs?