CurrencyPipe
pipe
npm Package | @angular/common |
---|---|
Module | import { CurrencyPipe } from '@angular/common'; |
Source | common/src/pipes/number_pipe.ts |
NgModule | CommonModule |
How To Use
number_expression | currency[:currencyCode[:symbolDisplay[:digitInfo]]]
Description
Use currency
to format a number as currency.
-
currencyCode
is the ISO 4217 currency code, such asUSD
for the US dollar andEUR
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
SeeDecimalPipe
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; }
© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/common/CurrencyPipe