विश्व का सबसे बड़ा हिंदी वेब डेवलपर साइट

AngularJS ng-model Directive


Bind the value of an input field to a variable in the scope:

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

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

Definition and Usage

The ng-model directive binds an HTML form element to a variable in the scope.

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


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

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

Parameter Values

Value Description
name The name of the property you want to bind to the form field.

Related pages

Angular Tutorial: ng-model Directive