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 the difference between angular 2 and 5 and 6 and 4?
What is dependency injection (di)?
What is difference between $interval and window. setInterval in AngularJS?
What are directives in angular?
What is platformbrowserdynamic?
Explain system.config.ts file used in angular?
How to create a service using factory in angularjs?
Explain the angularjs factory?
What are promises in angular 2?
What do you understand by constants in angular?
What is route guard?
How does the $resource `get` function work synchronously in angularjs ?