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 |
Write the cli command to generate a component in angular 4?
Explain ng-bind and ng-bind-html directives.
What is $rootscope in angularjs? How is it different from the scope?
What is transpiling?
What is the latest version of angular?
What's new in angular 6? What are improvements in angular 6?
What is auto bootstrap process in AngularJS?
What is difference between $document and window.document in AngularJS?
What are angular filters?
What is the factory method in angularjs?
What classes should I not add to module's declarations in angular 4?
What is ng init?