From ae0fce613fe2698ac7afcd29a6b66cd65bc1f67a Mon Sep 17 00:00:00 2001 From: cexbrayat Date: Mon, 25 Jun 2018 20:05:00 +0200 Subject: [PATCH] docs: more info on currency digits (#24661) Adds an example of using the `currency` pipe with a currency that has no cents like CLP, which will format the amount with no digits if `digitsInfo` is not provided: {{ 14 | currency:'CAD' }} {{ 14 | currency:'CLP' }} Amends the docs, adds an example and fix an error with a current example. PR Close #24661 --- packages/common/src/pipes/number_pipe.ts | 3 +++ packages/examples/common/pipes/ts/currency_pipe.ts | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/common/src/pipes/number_pipe.ts b/packages/common/src/pipes/number_pipe.ts index 8ad02f59b9..26a9cec33c 100644 --- a/packages/common/src/pipes/number_pipe.ts +++ b/packages/common/src/pipes/number_pipe.ts @@ -181,6 +181,9 @@ export class CurrencyPipe implements PipeTransform { * Default is `0`. * - `maxFractionDigits`: The maximum number of digits after the decimal point. * Default is `3`. + * If not provided, the number will be formatted with the proper amount of digits, + * depending on what the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) specifies. + * For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none. * @param locale 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](guide/i18n#setting-up-the-locale-of-your-app). diff --git a/packages/examples/common/pipes/ts/currency_pipe.ts b/packages/examples/common/pipes/ts/currency_pipe.ts index 23a700dbff..27565594cc 100644 --- a/packages/examples/common/pipes/ts/currency_pipe.ts +++ b/packages/examples/common/pipes/ts/currency_pipe.ts @@ -18,7 +18,7 @@ registerLocaleData(localeFr); @Component({ selector: 'currency-pipe', template: `
- +

A: {{a | currency}}

@@ -35,6 +35,9 @@ registerLocaleData(localeFr);

B: {{b | currency:'CAD':'symbol':'4.2-2':'fr'}}

+ + +

B: {{b | currency:'CLP'}}

` }) export class CurrencyPipeComponent {