WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS ng-model Directive


Example

Bind the estimation of an info field to a variable in the scope:

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

<script>
var application = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.name = "John Doe";
});
</script>
Try it yourself »

Definition and Usage

The ng-model mandate ties a HTML structure component to a variable in the scope.

If the variable does not exist in the degree, it will be created.


Syntax

<element ng-model="name"></element>

Supported by <input>, <select>, and <textarea> elements.


Parameter Values

Value Description
name The name of the property you need to tie to the structure field.

Related pages

Angular Tutorial: ng-model Directive