Tutorials References Exercises Bootcamps Videos Menu
Sign Up Create Website Get Certified Upgrade

AngularJS ng-value Directive


Set the value of the input field:

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

<input ng-value="myVar">


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

Definition and Usage

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


<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.