加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular4_格式化金钱或者重量

发布时间:2020-12-17 08:30:49 所属栏目:安全 来源:网络整理
导读:| number:'1.2-2' td {{item.weight| number:'1.2-2'}} / td 效果: 官网文档: DecimalPipe PIPE npm Package @angular/common Module import {DecimalPipe} from'@angular/common'; Source common/src/pipes/number_pipe.ts NgModule CommonModule Formats

| number:'1.2-2'


< td >{{item.weight| number:'1.2-2'}} </ td >

效果:

官网文档:

DecimalPipe

npm Package @angular/common
Module import {DecimalPipe} from'@angular/common';
Source common/src/pipes/number_pipe.ts
NgModule CommonModule

Formats a number according to locale rules.

How To Use

number_expression | number[:digitInfo[:locale]]

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

whereexpressionis a number:

  • digitInfois astringwhich has a following format:
    {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
  • minIntegerDigitsis the minimum number of integer digits to use. Defaults to1.
  • minFractionDigitsis the minimum number of digits after fraction. Defaults to0.
  • maxFractionDigitsis the maximum number of digits after fraction. Defaults to3.
  • localeis astringdefining the locale to use (uses the currentLOCALE_IDby default)

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

Example

  1. @Component({
  2. selector: 'number-pipe',
  3. template`<div>
  4. <!--output '2.718'-->
  5. <p>e (no formatting): {{e | number}}</p>
  6. <!--output '002.71828'-->
  7. <p>e (3.1-5): {{e | number:'3.1-5'}}</p>
  8. <!--output '0,002.71828'-->
  9. <p>e (3.5-5): {{e | number:'4.5-5'}}</p>
  10. <!--output '0002,71828'-->
  11. <p>e (french): {{e | number:'4.5-5':'fr'}}</p>
  12. <!--output '3.14'-->
  13. <p>pi (no formatting): {{e | number}}</p>
  14. <!--output '003.14'-->
  15. <p>pi (3.1-5): {{e | number:'3.1-5'}}</p>
  16. <!--output '003.14000'-->
  17. <p>pi (3.5-5): {{e | number:'3.5-5'}}</p>
  18. </div>`
  19. })
  20. exportclass NumberPipeComponent {
  21. pi number = 3.14;
  22. e2.718281828459045;
  23. }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读