加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 如何格式化ng中的数字:pluralize

发布时间:2020-12-17 07:31:26 所属栏目:安全 来源:网络整理
导读:如何通过attribtute’count’格式化传入ng:pluralize指令的数字? 考虑以下代码: ng:pluralize count="5000000" when="{'other': '{} things'}"/pluralize 输出是: 5000000 things 如何修改输出为: 5,000,000 things // in US locale5 000 000 things //
如何通过attribtute’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>

这会将值格式化为当前区域设置规则

演示:

> plunker

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读