例
格式化奖多项::
<div ng-app="myApp" ng-controller="nCtrl">
<h1>{{prize |
number}}</h1>
</div>
<script>
var app = angular.module('myApp',
[]);
app.controller('nCtrl', function($scope) {
$scope.prize = 1000000;
});
</script>
试一试» 定义和用法
该number
滤波器格式化一个数字的字符串。
句法
{{ string | number : fractionsize }}
参数值
Value | Description |
---|---|
fractionsize | A number, specifying the number of decimals. |
更多示例
例
显示重量与3位小数:
<div ng-app="myApp" ng-controller="nCtrl">
<h1>{{weight | number :
3}} kg</h1>
</div>
<script>
var app = angular.module('myApp',
[]);
app.controller('nCtrl', function($scope) {
$scope.weight = 9999;
});
</script>
试一试» 相关页面
AngularJS教程: 角过滤器