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 angular good for?
How do you use flexbox?
What is forgiving in angularjs?
How to use multiple ng-app within a page in angularjs?
What is pipes?
What are the securities threats should we be aware of in angular 2 applications?
What is import array in angular 2?
How to implement a datagrid table with angular 2 and primeng?
How to validate data in angular js?
What variables are used with ng-repeat?
What is shadow dom in angular?
What is single page application? How can the spa be implemented with angular?
What is the meaning of component lifecycle in angular 2?
What are the uses of controllers in angularjs?
How can I be lazy?