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 |
What is slug in angular?
What are the form validations supported by angularjs?
Can angularjs be used for backend?
What is shadow dom? How is it helping angular 2 to perform better?
Which of the Angular life cycle component execution happens when a data-bound input value updates?
What is transclusion in angularjs?
Why is angular called angular?
What is ngaftercontentinit?
What is an entry component?
What is the use of arrow function in angular 2?
Write ajax call syntax?
What is architecture overview of angular?