Skip to content

[Feature Request] Currency Pipe: improved digit info options #47479

Description

@karptonite

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: commonIssues related to APIs in the @angular/common packagearea: i18nIssues related to localization and internationalizationfeatureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions