用简单的管道限制到小数点后2位 [英] Limit to 2 decimal places with a simple pipe

查看:111
本文介绍了用简单的管道限制到小数点后2位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了一个示例,该示例将数字限制为两位小数,然后将数字转换为货币金额,例如2.55英镑.

I have found an example which limits a number to 2 decimal places AND turns the figure into a currency amount- eg £2.55.

{{ number | currency : 'GBP' : true : '1.2-2'}}

是否有一个简单的管道可以在不使用货币的情况下进行相同操作?

Is there a simple pipe which does the same without applying a currency?

推荐答案

货币管道使用

Currency pipe uses the number one internally for number formatting. So you can use it like this:

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

这篇关于用简单的管道限制到小数点后2位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆