How does AngularJS know when variables change? How does AngularJS dirty checking work?

From this link:

Angular defines a concept of a so called digest
cycle. This cycle can be considered as a loop, during which Angular
checks if there are any changes to all the variables watched by all
the $scopes. So if you have $scope.myVar defined in your controller
and this variable was marked for being watched, then you are
explicitly telling Angular to monitor the changes on myVar in each
iteration of the loop.

This “digest” is also called “dirty checking”, because, in a way, it scans the scope for changes. I cannot say if it’s for better or for worse than observable pattern. It depends on your needs.

Some links:

  • Angular documentation
  • A blog post about Angular scopes

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)