English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

AngularJS ng-value directive

AngularJS Reference Manual

AngularJS Example

Set the value of the input box:

<!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-value="myVar">
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.myVar = "Hello World!";
});
</script>
<p>This example demonstrates how to use AngularJS expressions to set the value of the input box.</p>/p>
</body>
</html>
Test to see ‹/›

Definition and Usage

ng-value The directive is used to set the value attribute of the input or select element.

Syntax

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

The <input> and <select> elements support this attribute.

Parameter Value

ValueDescription
expressionThe expression is used to set the value of the value attribute.

AngularJS Reference Manual