CurrencyPipe
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.
API
Description
Usage Notes
class CurrencyPipe implements PipeTransform {}
transform
3 overloads
@paramvalue
string | number
The number to be formatted as currency.
@paramcurrencyCode
string | undefined
The ISO 4217 currency code,
such as USD
for the US dollar and EUR
for the euro. The default currency code can be
configured using the DEFAULT_CURRENCY_CODE
injection token.
@paramdisplay
string | boolean | undefined
The format for the currency indicator. One of the following:
code
: Show the code (such asUSD
).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 symbolCA$
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. For example, an empty string will suppress the currency & symbol.
- Boolean (marked deprecated in v5):
true
for symbol and false forcode
.
@paramdigitsInfo
string | undefined
Decimal representation options, specified by a string
in the following format:
{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
.
minIntegerDigits
: The minimum number of integer digits before the decimal point. Default is1
.minFractionDigits
: The minimum number of digits after the decimal point. Default is2
.maxFractionDigits
: The maximum number of digits after the decimal point. Default is2
. 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.
@paramlocale
string | undefined
A locale code for the locale format rules to use.
When not supplied, uses the value of LOCALE_ID
, which is en-US
by default.
See Setting your app locale.
@returns
string | null
@paramvalue
null | undefined
@paramcurrencyCode
string | undefined
@paramdisplay
string | boolean | undefined
@paramdigitsInfo
string | undefined
@paramlocale
string | undefined
@returns
null
@paramvalue
string | number | null | undefined
@paramcurrencyCode
string | undefined
@paramdisplay
string | boolean | undefined
@paramdigitsInfo
string | undefined
@paramlocale
string | undefined
@returns
string | null
Jump to details