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
How install npm install?
What is httpinterceptor in angular?
How are angularjs prefixes $ and $$ used?
What are the differences between link and compile?
What are the components of a css style?
What is compile function in angularjs?
What is token based authentication in angular 4?
What is angulars performance like?
How do you define a module?
How to do Language Internationalization in AngularJS?
How does a controller work?
What would you have in a shared module?
What is the difference between ‘this’ vs $scope in angularjs controllers?
How angular.module works?
Explain ng-controller directive angularjs?