Below is my understanding of how binding happens in angularJS. It would be great if the experts could provide feedback / comment.
<div ng-controller="ctrlA">
{{myvar}}
{{anothervar}}
</div>
$scope.watch( function (scope) {
return scope.anothervar;
} , function (oldValue, newValue) {
});
$scope.watch( function (scope) {
return scope.myVar;
} , function (oldValue, newValue) {
});
As soon as angularJS meets {{myVar}} (and {{anothervar}}, an observer (for each variable) is created internally. This observer is created for the $ scope controller 'ctrlA'.
When functions are called in $ timeout, ng-click, etc., they are built into $ scope.apply (). After your function is executed (which may change some area variables), $ apply will cause a digest on rootScope. This will allow you to synchronize the variables throughout the application with the user interface!
$scope.digest , . , . , ( html, !).
. angularJS- - - ( - ) , ? - :
watch ref (for myvar) -> current value (of myvar)
watch ref (for anothervar) -> current value (of anothervar)