AngularJS Basic ng value Simple Example
- 2021-07-07 06:23:47
- OfStack
AngularJS ng-value Directive
AngularJS instance
Set the value of the input box:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/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 the AngularJS Expression to set the value of the input box. </p>
</body>
</html>
Definition and usage
The ng-value directives are used to set the value attribute of an input or select element.
Grammar
<
input ng-value="expression"
>
<
/input
>
<
input
>
And
<
select
>
Element supports this attribute.
Parameter value
值 | 描述 |
---|---|
expression | 表达式用于设置 value 属性的值。 |
The above is the AngularJS ng-value instruction data collation, follow-up to continue to supplement, thank you for your support to this site!