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
Here is an example of data binding with AngularJS, using an input field. I will explain later
HTML Code
{{watchInput}}
AngularJS Code
myApp = angular.module ("myApp", []);
myApp.controller("myCtrl", ["$scope", function($scope){
//Your Controller code goes here
}]);
As you can see in the example above, AngularJS uses ng-model
to listen and watch what happens on HTML elements, especially on input
fields. When something happens, do something. In our case, ng-model
is bind to our view, using the mustache notation {{}}
. Whatever is typed inside the input field is displayed on the screen instantly. And that's the beauty of data binding, using AngularJS in its simplest form.
Hope this helps.
See a working example here on Codepen