首页 > 代码库 > ng-model

ng-model

ng-model可双向绑定、验证表单、应用状态、提供css类

双向绑定:

<div ng-app= "myApp" ng-controller = "myCtrl">
    名字: <input ng-model = "name" />
</div>

<script>
var app = angular.module(‘myApp‘, []);
app.controller(‘myCtrl‘, function($scope){
  $scope.name = "allison"
});
</script>

  

ng-model