currency pipe

Transforms a number to a currency string, formatted according to locale rules that determine group sizing and separator, decimal-point character, and other locale-specific configurations.

Source
<p>A: {{a | currency}}</p>
<p>A: {{a | currency:'CAD'}}</p>
<p>A: {{a | currency:'CAD':'code'}}</p>
<p>B: {{b | currency:'CAD':'symbol':'4.2-2'}}</p>
<p>B: {{b | currency:'CAD':'symbol-narrow':'4.2-2'}}</p>
<p>B: {{b | currency:'CLP'}}</p>
export class AppComponent {
  a = 0.259;
  b = 1.3495;
}
Result

A: $0.26

A: CA$0.26

A: CAD0.26

B: CA$0,001.35

B: $0,001.35

B: CLP1

Parameters

{{ value_expression | currency [ : currencyCode [ : display [ : digitsInfo [ : locale ] ] ] ] }}

currencyCode#

The ISO 4217 currency code, such as USD for the US dollar and EUR for the euro.

currencyCode?: string

display#

The format for the currency indicator.

display: 'code'|'symbol'|'symbol-narrow'|string|boolean = 'symbol'

One of the following:

  • code: Show the code (such as USD).
  • symbol(default): Show the symbol (such as $).
  • symbol-narrow: Use the narrow symbol for locales that have two symbols for their currency.

For example, the Canadian dollar CAD has the symbol CA$ and the symbol-narrow $. If the locale has no narrow symbol, uses the standard symbol for the locale.

  • String: Use the given string value instead of a code or a symbol.
  • Boolean (marked deprecated in v5): true for symbol and false for code.

digitsInfo#

Decimal representation options.

digitsInfo?: string

Specified by a string in the following format:

{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.

If not provided, the number will be formatted with the proper amount of digits, depending on what the ISO 4217 specifies.

For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none.

locale#

A locale code for the locale format rules to use.

locale?: string

When not supplied, uses the value of LOCALE_ID, which is en-US by default. See Setting your app locale.