如何在NG格式化一个数字:复数 [英] How to format a number in ng:pluralize

查看:132
本文介绍了如何在NG格式化一个数字:复数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何格式化传递到NG了许多:通过attribtute计数复数指令

考虑以下code:

 < NG:复数数=5000000时={'其它':'{}东西'}>< /复数>

的输出是:

  500万的事情

我如何修改这个输出是:

  500万的事情//在美国地区
5 000 000 //东西捷克的语言环境

我试图使用过滤器'号',但我想我不知道在哪里把它。它不会传递给属性何时的目标努力。我想这些:

  ...当={多:{{{} |数}}的东西'}
...当={多:{} |数的东西'}
...当={多:{|}一些事情'}


解决方案

您需要将值分配给一个变​​量

 < NG:复数NG-的init =mycount的= 5000000数=mycount的当={'其它':'{{mycount的|数}}的东西'} >< / NG:复数>

这将值格式化当前语言环境规则

演示

How to format a number passed into ng:pluralize directive via attribtute 'count'?

Consider following code:

<ng:pluralize count="5000000" when="{'other': '{} things'}"></pluralize>

the output is:

5000000 things

How can I modify this for output to be:

5,000,000 things    // in US locale
5 000 000 things    // in Czech locale

I tried using filter 'number', but I think I don't know where to put it. It doesn't work in the object passed to attribute 'when'. I tried these:

... when="{'many': '{{{}|number}} things'}"
... when="{'many': '{}|number things'}"
... when="{'many': '{|number} things'}"

解决方案

You need to assign the value to a variable

 <ng:pluralize ng-init="myCount=5000000" count="myCount" when="{'other': '{{myCount|number}} things'}"></ng:pluralize>

This will format the value to the current locale rules

Demo:

这篇关于如何在NG格式化一个数字:复数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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