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:
Expanding on @Liviu T.'s answer, there's no real need to use ng-init to assign the variable. You can do it directly in count.
<ng:pluralize count="myCount=5000000" when="{'other': '{{myCount|number}} things'}"></ng:pluralize>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With