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 |
How does aot compiler work?
How to setup angular 4 development environment?
What's new in httpclient and httpclientmodule in angular?
What's new in angular 6?
What is lazy loading in c#?
What is rx observable?
What is constant in angularjs?
Why are decorators used in angular 2?
What is aot in angular?
How to create a custom errorhandler?
How can observable objects be defined as?
How to redirect to 404 or other path if the path does not exist in angular 2?