{ "id": "api/common/CurrencyPipe", "title": "CurrencyPipe", "contents": "\n\n
\n
\n
\n \n API > @angular/common\n
\n \n
\n \n
\n

CurrencyPipelink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

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

\n\n

See more...

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

NgModulelink

\n\n\n\n\n \n

Input valuelink

\n \n \n \n \n \n \n \n \n \n
\n \n value\n string | number\n \n \n
\n \n \n

Parameterslink

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n currencyCode\n string\n

Optional. Default is undefined.

\n \n
\n \n display\n string | boolean\n

Optional. Default is 'symbol'.

\n \n
\n \n digitsInfo\n string\n

Optional. Default is undefined.

\n \n
\n \n locale\n string\n

Optional. Default is undefined.

\n \n
\n \n
\n\n\n \n
\n

See alsolink

\n \n
\n\n\n \n\n
\n

Descriptionlink

\n \n
\n

Deprecation notice:

\n

The default currency code is currently always USD but this is deprecated from v9.

\n

In v11 the default currency code will be taken from the current locale identified by\nthe LOCALE_ID token. See the i18n guide for\nmore information.

\n

If you need the previous behavior then set it by creating a DEFAULT_CURRENCY_CODE provider in\nyour application NgModule:

\n\n{provide: DEFAULT_CURRENCY_CODE, useValue: 'USD'}\n\n
\n\n

Further information available in the Usage Notes...

\n
\n\n\n \n
\n

Usage noteslink

\n

The following code shows how the pipe transforms numbers\ninto text strings, according to various format specifications,\nwhere the caller's default locale is en-US.

\n\n@Component({\n selector: 'currency-pipe',\n template: `<div>\n <!--output '$0.26'-->\n <p>A: {{a | currency}}</p>\n\n <!--output 'CA$0.26'-->\n <p>A: {{a | currency:'CAD'}}</p>\n\n <!--output 'CAD0.26'-->\n <p>A: {{a | currency:'CAD':'code'}}</p>\n\n <!--output 'CA$0,001.35'-->\n <p>B: {{b | currency:'CAD':'symbol':'4.2-2'}}</p>\n\n <!--output '$0,001.35'-->\n <p>B: {{b | currency:'CAD':'symbol-narrow':'4.2-2'}}</p>\n\n <!--output '0 001,35 CA$'-->\n <p>B: {{b | currency:'CAD':'symbol':'4.2-2':'fr'}}</p>\n\n <!--output 'CLP1' because CLP has no cents-->\n <p>B: {{b | currency:'CLP'}}</p>\n </div>`\n})\nexport class CurrencyPipeComponent {\n a: number = 0.259;\n b: number = 1.3495;\n}\n\n\n\n
\n\n\n\n
\n
\n\n\n" }