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


Please Help Members By Posting Answers For Below Questions

What is a typescript decorator?

455


What is a template in angular7?

518


What are directives in angular?

423


What is a template angular?

381


What is scope hierarchy?

967






Why do we use ngmodel?

397


What is services and also explain its features in angular 2?

419


What is one way data binding in angularjs?

409


How to use the css binding in angular js?

461


How to use dependency injection (di) correctly in angular 2?

407


What does ng view do?

395


What is a promise in angular?

408


Does bootstrap require jquery?

415


What are dsl animation functions in angular js. List them.

466


What Are The Security Features Provided By AngularJS?

461