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.
- 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.
- User interaction with select element. AngularJS has selectDirective with similar behavior on 'change' event.
- Periodical changes using $timeout service that also do $rootScope.$apply().
- eventDirectives (ngClick, etc) also use scope.$apply.
- $http also uses $rootScope.$apply().
- Changes outside AngularJS world should use scope.$apply as you know.
As you found out it's not polling, but using it's internal execution loop so that's why you need to use $apply() or $digest() to kick things into motion.
Miško's explanation is quite thorough, but the bit missing is that Angular is just trying to make $scope get back to a clear internal state whenever anything happens within its own context. This might take quite some bouncing around between model states, so that's also why you can't rely on $watch() firing only once and also why you should be careful with manually setting up relations between models or you'll end up in endless circular refreshes.