Decimal Pipe in Angular 2 - Commas Only, No Decimal Places

39.9k Views Asked by At

I currently use this pipe {{ product.productPrice | number:'.2-2' }}

And result is 1,000,000.00 but I want to remove the .00 How do you do that?

1

There are 1 best solutions below

7
On BEST ANSWER

Use this :

  {{product.productPrice | number: '1.0-0'}}

1.0-0 means: at least one digit before decimal point, 0 digits after decimal point.

The general format is:

{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}

minIntegerDigits: The minimum number of integer digits before the decimal point. Default is 1.
minFractionDigits: The minimum number of digits after the decimal point. Default is 0. maxFractionDigits: The maximum number of digits after the decimal point. Default is 3.

https://angular.io/api/common/DecimalPipe