📜  角数管道 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:18.210000             🧑  作者: Mango

代码示例2
//{{ value_expression | number [ : digitsInfo [ : locale ] ] }}

//Assume someNumber = 12.221
    
    

{{ someNumber | number : '1.0-0'}}

//The output here is '12' because we cut the decimals off //with the number pipe //More examples from Angular: //Assume: //pi: number = 3.14; //e: number = 2.718281828459045;

e (no formatting): {{e | number}}

e (3.1-5): {{e | number:'3.1-5'}}

e (4.5-5): {{e | number:'4.5-5'}}

e (french): {{e | number:'4.5-5':'fr'}}

pi (no formatting): {{pi | number}}

pi (3.1-5): {{pi | number:'3.1-5'}}

pi (3.5-5): {{pi | number:'3.5-5'}}

-2.5 (1.0-0): {{-2.5 | number:'1.0-0'}}

//More information here: https://angular.io/api/common/DecimalPipe