With a look at the basic usage of ANGULARJS, here we'll follow the PDF to learn what the expression is about.
The expression in Angularjs is not exactly the same as in JS.
First, its expression is to be used in {{}}, followed by the concept of an expression in JavaScript, which differs from the following:
1 scopes differ
The default function in JavaScript so window, but in the Angularjs is different. It uses $scope control to function.
2 to allow undefined values
In Angularjs, if an undefined expression is used, no error occurs and a null value is returned directly.
3 Filters
you can use the | pipe command in an expression to add a filter, similar to the UNIX command line.
4 $ symbol
Methods used to distinguish angular from user-defined methods.
Let's look at a small piece of code:
<!doctype html>
<html ng-app>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script>
</head>
<body>
<div ng-controller="ctl">
name:<input ng-model="name" type="text">
<button ng-click="reset()">reset</button>
<br>
{{name}}
<br>
hello ! {{test}}
<br>
filter : {{name | uppercase}}
</div>
<script type="text/javascript">
function ctl($scope){
var str = "init";
$scope.name = str;
$scope.reset = function(){
$scope.name = str;
}
}
</script>
</body>
</html>
Reset the contents of the name variable by resetting the Reset method;
In an expression, the undefined test is referenced, but there is no error, and the default display is null;--{{test}
Finally, a filter is used to convert the value of name in an expression to uppercase. --{{name | uppercase}}
Run Result:
The above is the ANGULARJS expression of data collation, follow-up continue to supplement the relevant information, thank you for your support!