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 |
How do you resolve a template url relative to a component class?
What are http interceptors?
How many types of services are there in angularjs?
Write a code to upload an image in angularjs?
What are the difference between angular 6 and angular 7?
What are the data bindings m angular?
What is angular6?
What is "track by" in angularjs and how does it work?
What is angular stack?
How we can use styleurls and styles in angular 2?
Is angularjs hard to learn?
What is component in angular?