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

Explain the use of ng-if, ng-switch, and ng-repeat directives in angularjs?

0 Answers  


What is class in typescript?

0 Answers  


What is a module in a course?

0 Answers  


How to catch and log specific angular errors in your app?

0 Answers  


How to do animation in angularjs?

0 Answers  






Mention what are the styling form that model adds to css classes?

0 Answers  


Explain what is scope in angularjs?

0 Answers  


Ln component and service which logic that we have to write?

0 Answers  


What is primeng in angular?

0 Answers  


What is the benefit of angular?

0 Answers  


Is angularjs dependent on jquery?

0 Answers  


What is the basic need to start with AngularJS?

0 Answers  


Categories