AngularJS Number Filter

Definition and Usage

number Filters format numbers as strings.

Related Pages

AngularJS Tutorial:Angular Filters

Example

Example 1

Format the prize as a number:

<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>

Try It Yourself

Example 2

Display weight with 3 decimal places:

<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>

Try It Yourself

Syntax

{{ string | number : fractionsize}}

Parameter

Parameter Description
fractionsize Number, specify the number of decimal places after the decimal point.