Angular JS Two Way Binding
- In Angular JS two way binding is automatic synchronization of the data between model and view.
- Following sample will help you to understand better.
<body ng-app ng-init="firstName = 'Sathish'; lastName = 'kumar';"> <strong>First name:</strong> {{firstName}} <strong>Last name:</strong> <span ng-bind="lastName"></span> Set the first name: <input type="text" ng-model="firstName"/> Set the last name: <input type="text" ng-model="lastName"/>
</body>
Above Code binds the value in the view {{ firstName}} and ng-bind="lastName", When value is entered in the following input box <input type="text" ng-model="firstName"/> <input type="text" ng-model="lastName"/> In Angular JS two way binding can be acheived without writing any javascript events on the DOM object.
- ng-app - Defines the Angular JS template in the HTML markup for the application.
- ng-init - Initialize the data in the give variable .
- ng-model - Model is nothing but a variable stored in the scope.
- ng-bind - Binds the model/variable data in the specified DOM.
|
1 comment:
http://astutejs.blogspot.in/2015/06/angularjs-concetps.html
Post a Comment