Help Angular by taking a 1 minute survey!Go to surveyHome

CurrencyPipe

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 ] ] ] ] }}
      
      {{ 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 USD for the US dollar and EUR for the euro.

Optional. Default is undefined.

display string | boolean

The format for the currency indicator. One of the following:

  • code: Show the code (such as USD).
  • symbol(default): Show the symbol (such as $).
  • symbol-narrow: Use the narrow symbol for locales that have two symbols for their currency. For example, the Canadian dollar CAD has the symbol CA$ and the symbol-narrow $. If the locale has no narrow symbol, uses the standard symbol for the locale.
  • String: Use the given string value instead of a code or a symbol. For example, an empty string will suppress the currency & symbol.
  • Boolean (marked deprecated in v5): true for symbol and false for code.

Optional. Default is 'symbol'.

digitsInfo string

Decimal representation options, specified by a string in the following format:
{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}.

  • minIntegerDigits: The minimum number of integer digits before the decimal point. Default is 1.
  • minFractionDigits: The minimum number of digits after the decimal point. Default is 2.
  • maxFractionDigits: The maximum number of digits after the decimal point. Default is 2. If not provided, the number will be formatted with the proper amount of digits, depending on what the ISO 4217 specifies. For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none.

Optional. Default is undefined.

locale string

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.

Optional. Default is undefined.

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; }
      
      
  1. @Component({
  2. selector: 'currency-pipe',
  3. template: `<div>
  4. <!--output '$0.26'-->
  5. <p>A: {{a | currency}}</p>
  6.  
  7. <!--output 'CA$0.26'-->
  8. <p>A: {{a | currency:'CAD'}}</p>
  9.  
  10. <!--output 'CAD0.26'-->
  11. <p>A: {{a | currency:'CAD':'code'}}</p>
  12.  
  13. <!--output 'CA$0,001.35'-->
  14. <p>B: {{b | currency:'CAD':'symbol':'4.2-2'}}</p>
  15.  
  16. <!--output '$0,001.35'-->
  17. <p>B: {{b | currency:'CAD':'symbol-narrow':'4.2-2'}}</p>
  18.  
  19. <!--output '0 001,35 CA$'-->
  20. <p>B: {{b | currency:'CAD':'symbol':'4.2-2':'fr'}}</p>
  21.  
  22. <!--output 'CLP1' because CLP has no cents-->
  23. <p>B: {{b | currency:'CLP'}}</p>
  24. </div>`
  25. })
  26. export class CurrencyPipeComponent {
  27. a: number = 0.259;
  28. b: number = 1.3495;
  29. }