-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Description
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.