how does the binding and digesting work in AngularJS?

In addition to the documentation section found by Mark I think we can try to enumerate all possible sources of change.

  1. User interaction with HTML inputs (‘text’, ‘number’, ‘url’, ’email’, ‘radio’, ‘checkbox’). AngularJS has inputDirective. ‘text’, ‘number’, ‘url’ and ’email’ inputs bind listener handler for ‘input’ or ‘keydown’ events. Listener handler calls scope.$apply. ‘radio’ and ‘checkbox’ bind similar handler for click event.
  2. User interaction with select element. AngularJS has selectDirective with similar behavior on ‘change’ event.
  3. Periodical changes using $timeout service that also do $rootScope.$apply().
  4. eventDirectives (ngClick, etc) also use scope.$apply.
  5. $http also uses $rootScope.$apply().
  6. Changes outside AngularJS world should use scope.$apply as you know.

Leave a Comment