Which one handles exception automatically between $digest and $apply?
Answer Posted / 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 View All Answers
What are components in angular7?
What is an AsyncPipe in Angular?
What are the features of angular?
What are the ngmodule metadata properties?
How to use dependency injection (di) correctly in angular 2?
What are the features of angular 4.3?
What is impure pipe in angular?
Which is better react or angular?
Do you know what is angulars performance like?
What are the key features of angular.js?
What is event in angularjs?
What are the controllers in angular js?
What is activatedroute in routes?
Is ngmodel deprecated?
How would you make use of onnginit()?