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 is the use of restrict and template property when creating custom directives?
Is angular difficult?
What are the form validations supported by angularjs?
What is angular controllers?
What is ngmodel in angular?
Is angular a oop?
What is angularjs and what are some of its advantages?
What is data binding in angular?
What a digest cycle is in angularjs?
What is angular cli? List the command to install angular cli?
What is interceptor in angular?
How to bootstrap your angular app for multiple modules?
What are the methods available in $http ?
What is angular 5? Whats new in it?
Explain $q service, deferred and promises.