如何格式化通过属性“count”传递给 ng:pluralize 指令的数字?
考虑以下代码:
<ng:pluralize count="5000000" when="{'other': '{} things'}"></pluralize>
输出是:
5000000 things
我如何修改它的输出为:
5,000,000 things // in US locale
5 000 000 things // in Czech locale
我尝试使用过滤器“数字”,但我想我不知道把它放在哪里。它在传递给属性“when”的对象中不起作用。我试过这些:
... when="{'many': '{{{}|number}} things'}"
... when="{'many': '{}|number things'}"
... when="{'many': '{|number} things'}"
最佳答案
您需要将值分配给变量
<ng:pluralize ng-init="myCount=5000000" count="myCount" when="{'other': '{{myCount|number}} things'}"></ng:pluralize>
这会将值格式化为当前区域设置规则
演示 :
关于angularjs - 如何在 ng :pluralize 中格式化数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14002870/