DeprecatedCurrencyPipe

Formats a number as currency using locale rules.

查看"说明"...

{{ value_expression | currency [ : currencyCode [ : symbolDisplay [ : digits ] ] ] }}
      
      {{ value_expression | currency [ : currencyCode [ : symbolDisplay [ : digits ] ] ] }}
    

NgModule

输入值

value any

参数

currencyCode string

可选. 默认值是 'USD'.

symbolDisplay boolean

可选. 默认值是 false.

digits string

可选. 默认值是 undefined.

说明

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 DecimalPipefor 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: 'deprecated-currency-pipe', template: `<div> <!--output 'CAD0.26'--> <p>A: {{a | currency:'CAD'}}</p> <!--output '$0,001.35'--> <p>B: {{b | currency:'CAD':true:'4.2-2'}}</p> </div>` }) export class DeprecatedCurrencyPipeComponent { a: number = 0.259; b: number = 1.3495; }
      
      
  1. @Component({
  2. selector: 'deprecated-currency-pipe',
  3. template: `<div>
  4. <!--output 'CAD0.26'-->
  5. <p>A: {{a | currency:'CAD'}}</p>
  6.  
  7. <!--output '$0,001.35'-->
  8. <p>B: {{b | currency:'CAD':true:'4.2-2'}}</p>
  9. </div>`
  10. })
  11. export class DeprecatedCurrencyPipeComponent {
  12. a: number = 0.259;
  13. b: number = 1.3495;
  14. }