<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
原文链接:https://www.f2er.com/angularjs/148649.html