top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Which one handles exception automatically between $digest and $apply?

0 votes
355 views
Which one handles exception automatically between $digest and $apply?
posted Oct 24, 2017 by Latha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

When error occurs in one of the watchers, $digest() cannot handled errors via $exceptionHandler service,
In this case you have to handle exception yourself.
While $apply() uses try catch block internally to handle errors and if error occurs in one of the watchers then it
passes errors to $exceptionHandler service.
Pseudo-Code of $apply()

function $apply(expr) {
 try {
 return $eval(expr);
 } catch (e) {
 $exceptionHandler(e);
 } finally {
 $root.$digest();
 }
}
answer Oct 24, 2017 by Shivaranjini
...