I want to print numbers with commas as thousands
, lacs
, crores
separators. for e.g:
10,000 - ten thousand
1,00,000 - 1 lakh
10,00,000 - 10 lakh
1,00,00,000 - 1 crore
I have used angular's number pipe to implement comma separated values but not getting proper output it displays like this 1,000,000 - 10 lakh
.
How can i implement above functionality using angular/javascript or is there any pipe for this in angular?
Angular Currency Pipe without symbol If you want to display your own name instead of default currency symbol you have to pass display parameter. The display parameter can be “code” (currencycode will be displayed) or “symbol” or “symbol-narrow” or any other custom value.
If you don't need the decimal you can use the number pipe. The currency pipe is for formatting your numbers so you could use: {{2.56 | currency : 'USD' : 'symbol' : '1.0-0'}} but this will round your number up.
Transforms a number to a currency string, formatted according to locale rules that determine group sizing and separator, decimal-point character, and other locale-specific configurations.
You can use .toLocalString()
The toLocaleString() method returns a string with a language-sensitive representation of this number.
var tenK= 10000;
var oneL = 100000;
var tenL = 1000000;
var oneCr = 10000000;
console.log(tenK.toLocaleString('en-IN'));
console.log(oneL.toLocaleString('en-IN'));
console.log(tenL.toLocaleString('en-IN'));
console.log(oneCr.toLocaleString('en-IN'));
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