AngularJS filters are used to format/transform
the data displayed in the view, filters can be used with expressions, ng-bind,
ng-repeat etc and act upon the data from the model. The number filter is used to format numbers in the view
{{ <value/property> | number:<# decimal places> }}
The following is an example of using number filter.
<html ng-app>
<head>
<meta charset="utf-8" />
<title>AngularJS - Basic</title>
<script src="angular.min.js"></script>
</head>
<body>
<div ng-init="amount=10000.345">
<p>Output :<b> {{ amount | number }} </b></p>
<p>Output :<b> {{ amount | number : 0}} </b></p>
<p>Output :<b> {{ amount | number : 1}} </b></p>
<p>Output :<b> {{ amount | number : 2}} </b></p>
</div>
</body>
</html>
Output:
No comments:
Post a Comment