如何通过attribtute'count'格式化传入ng:pluralize指令的数字?
考虑以下代码:
<ng:pluralize count="5000000" when="{'other': '{} things'}"></pluralize>
Run Code Online (Sandbox Code Playgroud)
输出是:
5000000 things
Run Code Online (Sandbox Code Playgroud)
如何修改输出为:
5,000,000 things // in US locale
5 000 000 things // in Czech locale
Run Code Online (Sandbox Code Playgroud)
我尝试使用过滤器'数字',但我想我不知道在哪里放它.它在传递给属性'when'的对象中不起作用.我试过这些:
... when="{'many': '{{{}|number}} things'}"
... when="{'many': '{}|number things'}"
... when="{'many': '{|number} things'}"
Run Code Online (Sandbox Code Playgroud)
Liv*_* T. 13
您需要将值赋给变量
<ng:pluralize ng-init="myCount=5000000" count="myCount" when="{'other': '{{myCount|number}} things'}"></ng:pluralize>
Run Code Online (Sandbox Code Playgroud)
这会将值格式化为当前的语言环境规则
演示:
| 归档时间: |
|
| 查看次数: |
5211 次 |
| 最近记录: |