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
5840a86f98
commit
270176bbe4
|
@ -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).
|
||||
|
|
|
@ -18,7 +18,7 @@ registerLocaleData(localeFr);
|
|||
@Component({
|
||||
selector: 'currency-pipe',
|
||||
template: `<div>
|
||||
<!--output '$0.259'-->
|
||||
<!--output '$0.26'-->
|
||||
<p>A: {{a | currency}}</p>
|
||||
|
||||
<!--output 'CA$0.26'-->
|
||||
|
@ -35,6 +35,9 @@ registerLocaleData(localeFr);
|
|||
|
||||
<!--output '0 001,35 CA$'-->
|
||||
<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>`
|
||||
})
|
||||
export class CurrencyPipeComponent {
|
||||
|
|
Loading…
Reference in New Issue