5 lines
30 KiB
JSON
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"id": "api/common/CurrencyPipe",
"title": "CurrencyPipe",
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/common\", \"name\": \"@angular/common\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/common/CurrencyPipe\", \"name\": \"CurrencyPipe\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/common\">@angular/common</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/pipes/number_pipe.ts?message=docs(common)%3A%20describe%20your%20change...#L163-L287\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/pipes/number_pipe.ts#L163-L287\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"currencypipe\">CurrencyPipe<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/CurrencyPipe#currencypipe\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label pipe\">pipe</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>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.</p>\n\n <p><a href=\"api/common/CurrencyPipe#description\">See more...</a></p>\n </section>\n \n \n \n<section class=\"pipe-overview\">\n <code-example hidecopy=\"true\" class=\"no-box api-heading\">{{ value_expression | <span class=\"kwd nocode\">currency</span> [ : currencyCode [ : display [ : digitsInfo [ : locale ] ] ] ] }}</code-example>\n\n <h2 id=\"ngmodule\">NgModule<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/CurrencyPipe#ngmodule\"><i class=\"material-icons\">link</i></a></h2>\n<ul class=\"ngmodule-list\">\n\n <li>\n <a href=\"api/common/CommonModule\">\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">CommonModule</code-example>\n </a>\n </li>\n \n</ul>\n\n\n\n \n <h2 id=\"input-value\">Input value<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/CurrencyPipe#input-value\"><i class=\"material-icons\">link</i></a></h2>\n <table class=\"is-full-width list-table parameters-table pipe-parameters\">\n <tbody>\n \n <tr class=\"pipe-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>value</code>\n </td>\n <td class=\"param-type\"><code>string | <a href=\"api/common/DecimalPipe\" class=\"code-anchor\">number</a></code></td>\n <td class=\"param-description\">\n \n \n </td>\n </tr>\n </tbody>\n</table>\n \n \n <h2 id=\"parameters\">Parameters<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/CurrencyPipe#parameters\"><i class=\"material-icons\">link</i></a></h2>\n <table class=\"is-full-width list-table parameters-table pipe-parameters\">\n <tbody>\n \n <tr class=\"pipe-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>currencyCode</code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>Optional. Default is <code>undefined</code>.</p>\n \n </td>\n </tr>\n <tr class=\"pipe-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>display</code>\n </td>\n <td class=\"param-type\"><code>string | boolean</code></td>\n <td class=\"param-description\">\n <p>Optional. Default is <code>'symbol'</code>.</p>\n \n </td>\n </tr>\n <tr class=\"pipe-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>digitsInfo</code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>Optional. Default is <code>undefined</code>.</p>\n \n </td>\n </tr>\n <tr class=\"pipe-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>locale</code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>Optional. Default is <code>undefined</code>.</p>\n \n </td>\n </tr>\n </tbody>\n</table>\n \n</section>\n\n\n \n<section class=\"see-also\">\n <h2 id=\"see-also\">See also<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/CurrencyPipe#see-also\"><i class=\"material-icons\">link</i></a></h2>\n <ul>\n \n <li><p><code><a href=\"api/common/getCurrencySymbol\" class=\"code-anchor\">getCurrencySymbol</a>()</code></p>\n</li>\n <li><p><code><a href=\"api/common/formatCurrency\" class=\"code-anchor\">formatCurrency</a>()</code></p>\n</li>\n </ul>\n</section>\n\n\n \n\n<section class=\"description\">\n <h2 id=\"description\">Description<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/CurrencyPipe#description\"><i class=\"material-icons\">link</i></a></h2>\n <a id=\"currency-code-deprecation\"></a>\n<div class=\"alert is-helpful\">\n<p><strong>Deprecation notice:</strong></p>\n<p>The default currency code is currently always <code>USD</code> but this is deprecated from v9.</p>\n<p><strong>In v11 the default currency code will be taken from the current locale identified by\nthe <code><a href=\"api/core/LOCALE_ID\" class=\"code-anchor\">LOCALE_ID</a></code> token. See the <a href=\"guide/i18n#setting-up-the-locale-of-your-app\">i18n guide</a> for\nmore information.</strong></p>\n<p>If you need the previous behavior then set it by creating a <code><a href=\"api/core/DEFAULT_CURRENCY_CODE\" class=\"code-anchor\">DEFAULT_CURRENCY_CODE</a></code> provider in\nyour application <code><a href=\"api/core/NgModule\" class=\"code-anchor\">NgModule</a></code>:</p>\n<code-example language=\"ts\">\n{provide: <a href=\"api/core/DEFAULT_CURRENCY_CODE\" class=\"code-anchor\">DEFAULT_CURRENCY_CODE</a>, useValue: 'USD'}\n</code-example>\n</div>\n\n <p>Further information available in the <a href=\"api/common/CurrencyPipe#usage-notes\">Usage Notes</a>...</p>\n</section>\n\n\n \n<section class=\"usage-notes\">\n <h2 id=\"usage-notes\">Usage notes<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/CurrencyPipe#usage-notes\"><i class=\"material-icons\">link</i></a></h2>\n <p>The following code shows how the pipe transforms numbers\ninto text strings, according to various format specifications,\nwhere the caller's default locale is <code>en-US</code>.</p>\n<code-example path=\"common/pipes/ts/currency_pipe.ts\" region=\"CurrencyPipe\">\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'currency-pipe',\n template: `&#x3C;div>\n &#x3C;!--output '$0.26'-->\n &#x3C;p>A: {{a | <a href=\"api/common/CurrencyPipe\" class=\"code-anchor\">currency</a>}}&#x3C;/p>\n\n &#x3C;!--output 'CA$0.26'-->\n &#x3C;p>A: {{a | <a href=\"api/common/CurrencyPipe\" class=\"code-anchor\">currency</a>:'CAD'}}&#x3C;/p>\n\n &#x3C;!--output 'CAD0.26'-->\n &#x3C;p>A: {{a | <a href=\"api/common/CurrencyPipe\" class=\"code-anchor\">currency</a>:'CAD':'code'}}&#x3C;/p>\n\n &#x3C;!--output 'CA$0,001.35'-->\n &#x3C;p>B: {{b | <a href=\"api/common/CurrencyPipe\" class=\"code-anchor\">currency</a>:'CAD':'symbol':'4.2-2'}}&#x3C;/p>\n\n &#x3C;!--output '$0,001.35'-->\n &#x3C;p>B: {{b | <a href=\"api/common/CurrencyPipe\" class=\"code-anchor\">currency</a>:'CAD':'symbol-narrow':'4.2-2'}}&#x3C;/p>\n\n &#x3C;!--output '0 001,35 CA$'-->\n &#x3C;p>B: {{b | <a href=\"api/common/CurrencyPipe\" class=\"code-anchor\">currency</a>:'CAD':'symbol':'4.2-2':'fr'}}&#x3C;/p>\n\n &#x3C;!--output 'CLP1' because CLP has no cents-->\n &#x3C;p>B: {{b | <a href=\"api/common/CurrencyPipe\" class=\"code-anchor\">currency</a>:'CLP'}}&#x3C;/p>\n &#x3C;/div>`\n})\nexport class CurrencyPipeComponent {\n a: number = 0.259;\n b: number = 1.3495;\n}\n\n</code-example>\n\n</section>\n\n\n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/common\n - api/common/CommonModule\n - api/common/formatCurrency\n - api/core/PipeTransform\n - guide/ajs-quick-reference\n - guide/architecture-components\n - guide/deprecations\n - guide/i18n\n - guide/pipes\n - start/start-data\n - start/start-forms\n - start/start-routing\n-->\n<!-- links from this doc:\n - /api\n - api/common\n - api/common/CommonModule\n - api/common/CurrencyPipe#currencypipe\n - api/common/CurrencyPipe#description\n - api/common/CurrencyPipe#input-value\n - api/common/CurrencyPipe#ngmodule\n - api/common/CurrencyPipe#parameters\n - api/common/CurrencyPipe#see-also\n - api/common/CurrencyPipe#usage-notes\n - api/common/DecimalPipe\n - api/common/formatCurrency\n - api/common/getCurrencySymbol\n - api/core/Component\n - api/core/DEFAULT_CURRENCY_CODE\n - api/core/LOCALE_ID\n - api/core/NgModule\n - guide/i18n#setting-up-the-locale-of-your-app\n - https://github.com/angular/angular/edit/master/packages/common/src/pipes/number_pipe.ts?message=docs(common)%3A%20describe%20your%20change...#L163-L287\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/pipes/number_pipe.ts#L163-L287\n-->"
}