Q. What is two way data binding?
Q. How does angularjs detect the model changes?
A. In angulars $scope is the mother object for data sharing between model and view. It let us share any method or properties with view, that means if we want to share any method or properties with view these methods or properties should be member of this $scope object. So angularjs simply watch or observe $scope object in certain cases to check if there any changes that need to be reflected in the view. The process of checking the changes in the $scope object is termed as Dirty Checking as it checks the dirt/mutation of the object. angularjs uses a specially optimised loop for the purpose of Dirty Checking which is called digest cycle.
Q. What is digest cycle?
Q. How does angulajs add watcher to a scope?
A. 1. All angulajs expressions that have been used in the view will be added to the respective scope's watcher list automatically.
2. Manually i.e. Whenever $scope.watch() is used.
Q. Is there any permeant observer (i.e. Object.observer() or any timer) set for observing changes in the scope?
A. Is it fair? Definitely not.
Q. How does angularjs know when it needs to be run digest cycle?
A. When there is a possibility of changing scope. For example, IO operation (e.g. ajax), event (e.g. click, change). Thats why angularjs bound us to use ng-click instead of onclick, ng-change instead of onchange, $http service instead native ajax call, $timeout service instead settimeOut() so that it can run digest after completing event callback or ajax call or whatever. Finally you can invoke scope.digest() or scope.apply() to run digest cycle on demands.
Q. Is there any difference between scope.digest() or scope.apply() ?
A. scope.apply() always start digest cycle iteration starting from rootScope whereas scope.digest() start digest cycle iteration starting from invoking scope. So whenever you are sure about scope changes and it won't affect parent scope, use scope.digest() instead of scope.apply() if you are caring about performance.
Use angularjs wisely :)