Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
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.