AngularJS ng-valueDirective
AngularJS Examples
Set the value of the input box:
<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>
<input ng-value="myVar">
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.myVar = "Hello World!";
});
</script>
Try it »
Definition and Usage
ng-valueThe directive is used to set the value attribute of input or select elements.
Syntax
<input ng-value="expression"></input>
<input> and <select> elements support this attribute.
Parameter Value
| Value | Description |
|---|---|
| expression | The expression is used to set the value of the value attribute. |
Other Extensions
AngularJS Reference Manual