angularpipedecimal

Limit to 2 decimal places with a simple pipe


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?


Solution

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

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