Warm tip: This article is reproduced from stackoverflow.com, please click
angular decimal pipe

Limit to 2 decimal places with a simple pipe

发布于 2020-04-11 11:37:18

I have found an example which limits a number to 2 decimal places AND turns the figure into a currency amount- eg £2.55.

{{ number | currency : 'GBP' : true : '1.2-2'}}

Is there a simple pipe which does the same without applying a currency?

Questioner
rushtoni88
Viewed
65
dfsq 2016-07-19 18:41

Currency pipe uses the number one internally for number formatting. So you can use it like this:

{{ number | number : '1.2-2'}}