Data binding – bidirectional binding

  • Data bidirectional binding: the view data can be bound to the model, and the data of the model can be bound to the view
  • To implement the data binding of views to the model, you must use the form, and use the ng-model command in the form to bind the attributes in the input tag
< body ng-app='app'ng-controller='xmgConreoller'> < h1> {{name}}< /h1> < input type='text' ng-model=''userName> < input; type='password'ng-model='pwd'> < button; ng-click='login ('>); < / button> log; < /body> < script> VAR app = angular.module ('app', []) ('xmgController', ['$scope', app.controller; function ($scope) {$ ='hu'; $scope.login = function / events () {/ / click can print directly bind a view into the model data of alert ($scope.userName+$scope.pwd);};}]); < /script>