AngularJs: How to format numbers in template?

AngularJS provides number filter to format numbers in different ways. You can display numbers in various formats using the number filter in your template.

Basic syntax to use number filter in your template is like below,

Based on your locale, number filter will return the number with correct format and decimal points. For example, if your local is en_UK, it will use “,” as group separator and “.” as decimal point e.g. 123,456.89. If your locale is set to tr_TR, it will use “.” as group separator and “,” as decimal separator e.g. 123.456,89.

You can define the number of decimal places using fractionSize attribute.

Example

 

You may also like...

  • Very helpful example and code.

    Thanks for this post.