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

What string interpolation is in angularjs?

0 Answers  


Why we need ngmodel in angular 4?

0 Answers  


In which directory all external modules and files are stored in angular 4?

0 Answers  


What is directive advice?

0 Answers  


What is @outputs in angular?

0 Answers  






Is mvc front end or backend?

0 Answers  


How to share information between controllers in AngularJS?

1 Answers  


How to detect swipe event in mobile browsers/devices in AngularJS?

0 Answers  


Is angular difficult to learn?

0 Answers  


Why should use angular js?

0 Answers  


Explain what is linking function and type of linking function?

0 Answers  


What is services in angular?

0 Answers  


Categories