CurrencyPipe

Stable Pipe

What it does

Formats a number as currency using locale rules.

How to use

number_expression | currency[:currencyCode[:symbolDisplay[:digitInfo]]]

NgModule

CommonModule

Description

Use currency to format a number as currency.

  • currencyCode is the ISO 4217 currency code, such as USD for the US dollar and EUR for the euro.
  • symbolDisplay is a boolean indicating whether to use the currency symbol or code.
    • true: use symbol (e.g. $).
    • false(default): use code (e.g. USD).
  • digitInfo See DecimalPipe for detailed description.

WARNING: this pipe uses the Internationalization API which is not yet available in all browsers and may require a polyfill. See Browser support for details.

Example

@Component({
  selector: 'currency-pipe',
  template: `<div>
    <p>A: {{a | currency:'USD':false}}</p>
    <p>B: {{b | currency:'USD':true:'4.2-2'}}</p>
  </div>`
})
export class CurrencyPipeComponent {
  a: number = 0.259;
  b: number = 1.3495;
}

exported from @angular/common/index defined in @angular/common/src/pipes/number_pipe.ts

doc_Angular
2016-10-06 09:46:24
Comments
Leave a Comment

Please login to continue.