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.
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.
可选. 默认值是 undefined.
display
string | boolean
货币指示器的格式,有效值包括:
The format for the currency indicator. One of the following:
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: 使用指定的字符串值代替货币代码或符号。 比如,空字符串将会去掉货币代码或符号。
String: Use the given string value instead of a code or a symbol. For example, an empty string will suppress the currency & symbol.
Boolean(从 v5 开始已弃用):true 表示货币符号,false 表示货币代码。
Boolean (marked deprecated in v5): true for symbol and false for code.
Decimal representation options, specified by a string in the following format: {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}.
minIntegerDigits:在小数点前的最小位数。默认为 1。
minIntegerDigits: The minimum number of integer digits before the decimal point. Default is 1.
minFractionDigits:小数点后的最小位数。默认为 0。
minFractionDigits: The minimum number of digits after the decimal point. Default is 2.
maxFractionDigits:小数点后的最大为数,默认为 3。 如果没有提供,该数字就会根据 ISO 4217 规范进行适当的格式化。 比如,加拿大元具有 2 位数字,而智利比索则没有。
maxFractionDigits: The maximum number of digits after the decimal point. Default is 2. 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.
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.
The following code shows how the pipe transforms numbers into text strings, according to various format specifications, where the caller's default locale is en-US.