CurrencyPipe
pipe
Transforms a number to a currency string, formatted according to locale rules that determine group sizing and separator, decimal-point character, and other locale-specific configurations.
{{ value_expression | currency [ : currencyCode [ : display [ : digitsInfo [ : locale ] ] ] ] }}
NgModule
Input value
value | any | The number to be formatted as currency. |
Parameters
currencyCode | string | The ISO 4217 currency code, such as Optional. Default is |
display | string | boolean | The format for the currency indicator. One of the following:
Optional. Default is |
digitsInfo | string | Decimal representation options, specified by a string in the following format:
Optional. Default is |
locale | string | A locale code for the locale format rules to use. When not supplied, uses the value of Optional. Default is |
See also
Usage notes
The following code shows how the pipe transforms numbers into text strings, according to various format specifications, where the caller's default locale is en-US
.
@Component({ selector: 'currency-pipe', template: `<div> <!--output '$0.26'--> <p>A: {{a | currency}}</p> <!--output 'CA$0.26'--> <p>A: {{a | currency:'CAD'}}</p> <!--output 'CAD0.26'--> <p>A: {{a | currency:'CAD':'code'}}</p> <!--output 'CA$0,001.35'--> <p>B: {{b | currency:'CAD':'symbol':'4.2-2'}}</p> <!--output '$0,001.35'--> <p>B: {{b | currency:'CAD':'symbol-narrow':'4.2-2'}}</p> <!--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 { a: number = 0.259; b: number = 1.3495; }
© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v7.angular.io/api/common/CurrencyPipe