The following is one of the uses of Angularjs two-way data binding: User input box input information, with user information input, information is displayed in an element at any time
Two-way data binding if you do not need to have any action on the input data, just display the user input information in the page, you do not need to <div ng-app= ' > inside any of the words, only need to xiewei empty characters, a user input information element binding ng-model= ' name ', the display element is bound in the following two ways can be implemented
Mode one: ng-bind= ' name '
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> two ways of data binding </title>
<script src= "Angular.js" ></script>
<body >
ng-app= "">
ng-model= "name"/>
ng-bind= "name"></div> <!--ng-bind Mode--
</div>
</body>
Mode two: Curly brace form {{name}}
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> two ways of data binding </title>
<script src= "Angular.js" ></script>
<body >
<div ng-app= "" >
ng-model= "name"/>
<div>{{name}}</div> <!--curly Braces--
</div>
</body>
The results shown are:
Two-way data binding in this way to achieve a change with the ability to display at any time, do not need to do complicated JS or JS operation
angularjs-input box information of bidirectional data binding is displayed at any time