352229 (9) [Avatar] Offline
I have read that ng-model - binds the value of HTML controls (input, select, textarea) to application data. Now in the code
<input type="text" ng-model="name"></p>
. How does that work behind the scenes
Lukas Ruebbelke (107) [Avatar] Offline
ng-model basically hooks into the Angular digest cycle so that a digest cycle is kicked off when the value of the input changes. Please let me know if you would like me to elaborate further.
352229 (9) [Avatar] Offline
Hi Lukas

Thanks for the reply. When I say Digest cycle and ng-model does it mean that dirty checking is done. For example if we have a textbox and a span tag. In the textbox I have added an attribute ng-model = 'name' and in the span I have put {{name}}. So angular.js will do dirty checking i.e. checks if the value of textbox is same as previous value. If not then it updates span as well.

Lukas Ruebbelke (107) [Avatar] Offline
That is correct. Angular detects that the value in the text input is 'dirty' and kicks of a digest cycle to synchronize everything.