角度-将小数位数限制为两个位数而不四舍五入

时间:2019-02-26 10:47:12

标签: angular

我正在使用decimal pipe将十进制数限制在两个位置:

{{amount | number:'1.2-2'}}

但不幸的是,上述管道将数字四舍五入。有什么办法可以将输出限制为小数点后两位,而无需四舍五入。

1 个答案:

答案 0 :(得分:1)

我建议您编写一个自定义管道来完成此操作。

可在此处找到文档:

https://angular.io/guide/pipes#custom-pipes

这是一个很好的示例,说明如何使用管道来格式化数字

Angular 2 - Number pipe for scientific notation numbers

相关问题