Which one handles exception automatically between $digest and $apply?



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

Post New Answer

More AngularJS Interview Questions

How do you resolve a template url relative to a component class?

0 Answers  


What are http interceptors?

0 Answers  


How many types of services are there in angularjs?

0 Answers  


Write a code to upload an image in angularjs?

0 Answers  


What are the difference between angular 6 and angular 7?

0 Answers  






What are the data bindings m angular?

0 Answers  


What is angular6?

0 Answers  


What is "track by" in angularjs and how does it work?

0 Answers  


What is angular stack?

0 Answers  


How we can use styleurls and styles in angular 2?

0 Answers  


Is angularjs hard to learn?

0 Answers  


What is component in angular?

0 Answers  


Categories