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?
Currency pipe uses the number
one internally for number formatting. So you can use it like this:
{{ number | number : '1.2-2'}}
refer for details regarding using number pipe
This was helpful in understanding why
1.2-2
stackoverflow.com/questions/38477970/…For future readers,
{{ x | number : '1.2'}}
is also valid and means the same thing.mehaase, is not the same. For example if you have 5.6 and 5.6789 the output will be 5.60 and 5.6789. So, the first parameter is the min and the second is the number of maximum digits.
How to use Pipe to transform a number to 1 decimal place and without roundup. Ex: 345.678 => 345.6