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
What is httpinterceptor in angular?
Explain the steps for creating a services in angular 2?
Can multiple controllers be used in a single html page?
Explain data binding in angular 4?
How would you make use of onnginit()?
What is single page application in angularjs?
What is an oauth token?
Explain npm?
What is the new in angular 7?
What is factory method in angular.js?
What is difference between component and module in angular?
What are ngModel and how do we represent it?
What does pipe do in rxjs?
Explain the difference between promise and observable in angular?
Is angular 2 mobile oriented?