How does data binding work in AngularJS?

By : Pashec
Source: Stackoverflow.com
Question!

How does data binding work in the AngularJS framework?

I haven't found technical details on their site. It's more or less clear how it works when data is propagated from view to model. But how does AngularJS track changes of model properties without setters and getters?

I found that there are JavaScript watchers that may do this work. But they are not supported in Internet Explorer 6 and Internet Explorer 7. So how does AngularJS know that I changed for example the following and reflected this change on a view?

myobject.myproperty="new value";
By : Pashec


Answers

Angular.js creates a watcher for every model we create in view. Whenever a model is changed, an "ng-dirty" class is appeneded to the model, so the watcher will observe all models which have the class "ng-dirty"



AngularJs supports Two way data-binding.
Means you can access data View -> Controller



Here is an example of data binding with AngularJS, using an input field. I will explain later

HTML Code

By : AllJs


This video can help you solving your question :)
By: admin