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: <!-- outputs CA$14.00 --> {{ 14 | currency:'CAD' }} <!-- outputs CLP14 --> {{ 14 | currency:'CLP' }} Amends the docs, adds an example and fix an error with a current example. PR Close #24661
This commit is contained in:
parent
422de27601
commit
ae0fce613f
@ -181,6 +181,9 @@ export class CurrencyPipe implements PipeTransform {
|
|||||||
* Default is `0`.
|
* Default is `0`.
|
||||||
* - `maxFractionDigits`: The maximum number of digits after the decimal point.
|
* - `maxFractionDigits`: The maximum number of digits after the decimal point.
|
||||||
* Default is `3`.
|
* 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.
|
* @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.
|
* 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).
|
* See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
|
||||||
|
@ -18,7 +18,7 @@ registerLocaleData(localeFr);
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'currency-pipe',
|
selector: 'currency-pipe',
|
||||||
template: `<div>
|
template: `<div>
|
||||||
<!--output '$0.259'-->
|
<!--output '$0.26'-->
|
||||||
<p>A: {{a | currency}}</p>
|
<p>A: {{a | currency}}</p>
|
||||||
|
|
||||||
<!--output 'CA$0.26'-->
|
<!--output 'CA$0.26'-->
|
||||||
@ -35,6 +35,9 @@ registerLocaleData(localeFr);
|
|||||||
|
|
||||||
<!--output '0 001,35 CA$'-->
|
<!--output '0 001,35 CA$'-->
|
||||||
<p>B: {{b | currency:'CAD':'symbol':'4.2-2':'fr'}}</p>
|
<p>B: {{b | currency:'CAD':'symbol':'4.2-2':'fr'}}</p>
|
||||||
|
|
||||||
|
<!--output 'CLP1' because CLP has no cents-->
|
||||||
|
<p>B: {{b | currency:'CLP'}}</p>
|
||||||
</div>`
|
</div>`
|
||||||
})
|
})
|
||||||
export class CurrencyPipeComponent {
|
export class CurrencyPipeComponent {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user