Which @angular/* package(s) are relevant/related to the feature request?
common
Description
A common way to display currencies (at least in US) is to omit the cents if the price is a round number, or to show two digits if the price is not a round number.
For example, for 3 dollars, $3, and for 3.1 dollar, $3.10.
There is no way to accomplish this with the current currency pipe, which only takes a range for the number of digits after the decimal. The only options either make the first price $3.00 and the second $3.10, or the first price $3 and the second $3.1.
Proposed solution
Extend the digitsInfo format. Currently, the format is {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}.
As an alternative, we could offer {minIntegerDigits}.{allowedFractionDigits1},{allowedFractionDigits2}[,...]. So the digitsInfo for the format above would be 1.0,2.
Alternatives considered
Alternately, one could use an *ngIf to change out the element with the currency, and use two elements, each with a currency pipe to accomplish the above. Obviously, that is kind of messy.
Which @angular/* package(s) are relevant/related to the feature request?
common
Description
A common way to display currencies (at least in US) is to omit the cents if the price is a round number, or to show two digits if the price is not a round number.
For example, for
3dollars,$3, and for3.1dollar,$3.10.There is no way to accomplish this with the current currency pipe, which only takes a range for the number of digits after the decimal. The only options either make the first price
$3.00and the second$3.10, or the first price$3and the second$3.1.Proposed solution
Extend the
digitsInfoformat. Currently, the format is{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}.As an alternative, we could offer
{minIntegerDigits}.{allowedFractionDigits1},{allowedFractionDigits2}[,...]. So thedigitsInfofor the format above would be1.0,2.Alternatives considered
Alternately, one could use an
*ngIfto change out the element with the currency, and use two elements, each with a currency pipe to accomplish the above. Obviously, that is kind of messy.