ng-model
Chỉ thị AngularJS
Thí dụ
Liên kết giá trị của một trường đầu vào với một biến trong phạm vi:
<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
= "John Doe";
});
</script>
Định nghĩa và Cách sử dụng
Lệnh ng-model
liên kết một phần tử biểu mẫu HTML với một biến trong phạm vi.
Nếu biến không tồn tại trong phạm vi, nó sẽ được tạo.
Cú pháp
<element ng-model="name"></element>
Được hỗ trợ bởi các phần tử <input>, <select> và <textareosystem.
Giá trị tham số
Value | Description |
---|---|
name | The name of the property you want to bind to the form field. |
Các trang liên quan
Hướng dẫn Angular: Chỉ thị Mô hình