angular2 decimal pipe 学习

<p>e (no formatting): {{e}}</p>
<p>e (3.1-5): {{e | number:'3.1-5'}}</p>
<p>e (2.1-5): {{e | number:'2.1-5'}}</p>
<p>e (1.1-2): {{e | number:'1.1-2'}}</p>
<p>pi (no formatting): {{pi}}</p>
<p>pi (3.5-5): {{pi | number:'3.5-5'}}</p>
<p>pi (3.1-5): {{pi | number:'3.1-5'}}</p>
<p>pi (1.1-5): {{pi | number:'1.1-2'}}</p>
<p>str (1.1-5): {{ str | number: '1.1-5' }}</p>


<p>digitInfo is a string which has a following format:</p>
<p>"{{ '{' }}" minIntegerDigits "{{ '}' }}"."{{ '{' }}" minFractionDigits "{{ '}' }}" - "{{ '{' }}" maxFractionDigits"{{ '}' }}" </p>
<p>minIntegerDigits is the minimum number of integer digits to use. Defaults to 1.(最低整数,默认为1)</p>
<p>minFractionDigits is the minimum number of digits after fraction. Defaults to 0.(最低小数位数,默认为0)</p>
<p>maxFractionDigits is the maximum number of digits after fraction. Defaults to 3.(最多小数位数,默认为3)</p>
export class TestComponent {

    pi: number = 3.141592;
    e: number = 2.718281828459045;
    str:string = '12.11111111';

}

展现效果:

e (no formatting): 2.718281828459045

e (3.1-5): 002.71828

e (2.1-5): 02.71828

e (1.1-2): 2.72

pi (no formatting): 3.141592

pi (3.5-5): 003.14159

pi (3.1-5): 003.14159

pi (1.1-5): 3.14

str (1.1-5): 12.11111

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...