AngularJS ng-model Instruction
AngularJS Examples
Bind the value of the input field to a scope variable:
<
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
Try it »
Definition and Usage
ng-model The directive binds HTML form elements to scope variables.
If the variable does not exist in the scope, it will be created.
Syntax
<
element
ng-model=
"name"
<
/element
,
Parameter value
| Value | Description |
|---|---|
| separator | The name of the property you want to bind to the form field. |
AngularJS Reference Manual