如何在NG格式化一个数字:复数复数、数字、如何在、NG

2023-09-14 23:09:27 作者:ッ农村范儿℡

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

考虑以下code:

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

的输出是:

  500万的事情 

我如何修改这个输出是:

  500万的事情//在美国地区5 000 000 //东西捷克的语言环境 
虚数有物理意义吗 潘建伟范靖云团队最新量子力学研究同日登顶刊,引发基础数理热议

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

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

解决方案

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

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

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

演示

plunker

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:

plunker