THE INDIA LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS number Filter


Example

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 »

Definition and Usage

The number filter formats a number to a string.


Syntax

{{ string | number : fractionsize}}

Parameter Values

Value Description
fractionsize  A number, specifying the number of decimals.

More Examples

Example

Display the weight with 3 decimals:

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

Related Pages

AngularJS Tutorial: Angular Filters