English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js></script> </head> <body> <div ng-app="myApp" ng-controller="myCtrl"> <input ng-model="name"> <p>The value of the input box is bound to the variable "name":</p> {{name}} </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.name = "John Doe"; }); </script> <p>This example demonstrates how to use the ng-The model directive binds the value of the input box to the scope variable.</p> </body> </html>Test to see ‹/›
ng-model The directive binds the HTML form element to the scope variable.
If the variable does not exist in the scope, it will be created.
<element ng-model="name"></element>
<input>, <select>, <textarea> elements support this directive.
Value | Description |
---|---|
separator | The attribute name you want to bind to the form field. |