THE WORLD'S LARGEST WEB DEVELOPER SITE

AngularJS ng-value Directive


Example

Set the value of the input field:

<div ng-app="myApp" ng-controller="myCtrl">

<input ng-value="myVar">

</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.myVar = "Hello World!";
});
</script>
Try it Yourself »

Definition and Usage

The ng-value directive sets the value attribute of a input element, or a select element.


Syntax

<input ng-value="expression"></input>

Supported by <input> and <select> elements.


Parameter Values

Value Description
expression An expression that will set the element's value attribute.