Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

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.