Skip to content

DEFAULT_CURRENCY_CODE is not the right way for default currency code #41323

@e-cloud

Description

@e-cloud

🚀 feature request

Relevant Package

@angular/common

Description

With current implementation, developers have to mannually specify the DEFAULT_CURRENCY_CODE, if they use a different locale rather than en-us and want to use the currency meta along with that locale.

here is how currency pipe implements:

export class CurrencyPipe implements PipeTransform {
constructor(
@Inject(LOCALE_ID) private _locale: string,
@Inject(DEFAULT_CURRENCY_CODE) private _defaultCurrencyCode: string = 'USD') {}

In fact, there is a function to get currency code from a target locale

export function getLocaleCurrencyCode(locale: string): string|null {

I believe using the currency code from specified locale is the right way to go, rather than specifying it mannually.

Describe the solution you'd like

deprecate the use of DEFAULT_CURRENCY_CODE, in favor of getLocaleCurrencyCode in currency pipe.

Describe alternatives you've considered

There are always the alternatives, but not the elegant way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions