Currency Format Pipe
Overview
Formats a number into currency string. Group sizing and separator and other locale-specific configurations are based on the pattern data.
Usage
{{ value | currencyFormat [ : currencyCode [ : formatOptions ] ] }}
Input Value
Parameter | Type | Description |
---|---|---|
value | number / string | The number to be formatted. |
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
currencyCode | string | Optional | Currency code should be in accordance with ISO 4217 standard, such as USD for the US dollar and EUR for the euro. Optional. Default value is USD. |
formatOptions | object | Optional | The results formats can be customized using the formatOptions argument. See formatOptions for further details. |
formatOptions
Attribute | Type | Required | Description |
---|---|---|---|
minIntegerDigits | number | Optional | The minimum digits of integer numbers used. The possible values are from 1 to 21, and the default value is 1. |
minFractionDigits | number | Optional | The minimum digits of fraction numbers used. The possible values are from 0 to 20. The default value comes from ISO 4217 currency code list (if the list is not provided, the default value is 2). |
maxFractionDigits | number | Optional | The maximum digits of fraction numbers used. The possible values are from 0 to 20. The default value is taken the larger of minimumfractiondigits and ISO 4217 currency code list (if the list is not provided, the default value is 2). |
notation | string | Optional | The format in which this number should be displayed. For now only support ‘compact’ for compact number formats. The default is “standard”. |
compactDisplay | string | Optional | The ‘compactDisplay’ is only used when notation is “compact”. The possible value is “short” (default) or “long”, and the default value is “short”. |
Example Code
// input '201703.5416926'
{{ num | currencyFormat }}
// output '$201,703.54'
// input '1.149999'
{{ num | currencyFormat: 'JPY' }}
// output '¥1'
// input '1.149999'
{{ num | currencyFormat: 'JPY': { minFractionDigits: 6 } }}
// output '¥1.149999'
// input '2.31'
{{ num | currencyFormat: 'CNY' }}
// output 'CN¥2.31'
// input '2017120107'
{{ num | currencyFormat: 'EUR' }}
// output '€2,017,120,107.00'
// Format options usages
// Please note that pass object as a parameter,
// the end of the brace should keep a whitespace.
// input '2017120107'
{{ num | currencyFormat: 'EUR': {notation: 'compact', compactDisplay: 'short'} }}
// output '€2.02B'
// input '2017120107'
{{ num | currencyFormat: 'EUR': {notation: 'compact', compactDisplay: 'long'} }}
// output '€2.02 billion'