DeprecatedDecimalPipe

Formats a number as text. Group sizing and separator and other locale-specific configurations are based on the active locale.

查看"说明"...

{{ value_expression | number [ : digits ] }}
      
      {{ value_expression | number [ : digits ] }}
    

NgModule

输入值

value any

参数

digits string

可选. 默认值是 undefined.

说明

where expression is a number:

  • digitInfo is a string which has a following format:
    {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
  • minIntegerDigits is the minimum number of integer digits to use. Defaults to 1.
  • minFractionDigits is the minimum number of digits after fraction. Defaults to 0.
  • maxFractionDigits is the maximum number of digits after fraction. Defaults to 3.

For more information on the acceptable range for each of these numbers and other details see your native internationalization library.

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-number-pipe', template: `<div> <p>e (no formatting): {{e}}</p> <p>e (3.1-5): {{e | number:'3.1-5'}}</p> <p>pi (no formatting): {{pi}}</p> <p>pi (3.5-5): {{pi | number:'3.5-5'}}</p> </div>` }) export class DeprecatedNumberPipeComponent { pi: number = 3.141592; e: number = 2.718281828459045; }
      
      
  1. @Component({
  2. selector: 'deprecated-number-pipe',
  3. template: `<div>
  4. <p>e (no formatting): {{e}}</p>
  5. <p>e (3.1-5): {{e | number:'3.1-5'}}</p>
  6. <p>pi (no formatting): {{pi}}</p>
  7. <p>pi (3.5-5): {{pi | number:'3.5-5'}}</p>
  8. </div>`
  9. })
  10. export class DeprecatedNumberPipeComponent {
  11. pi: number = 3.141592;
  12. e: number = 2.718281828459045;
  13. }