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
When latest angularjs was released?
What is angular cli? List the command to install angular cli?
What is router imports?
How can a number of watchers and digest cycle time affect the performance of the application?
List the types of data binding supported by angular 5?
What is binding in java?
What is single page application (spa)?
How to using looping through a collection for each item in angular js?
What is the template in angularjs?
How will you show/hide buttons and enable/disable buttons conditionally?
Explain service worker in reference to angular js?
What are directives in angular7?
What is $rootscope in angularjs? How is it different from the scope?
What is event binding in angular?
Write all the steps to configure an angular app(ng-app).