-3

I need to enter a number in input element with comma separated and once user hit tab or click outside the input element need to append zero. Below are the scenario:

1] 123456789.12345678 -> 123,456,789.12345678
2] 123456789.1234     -> 123,456,789.12340000
3] 123456.1234        -> 123,456.12340000
Rahul Pawar
  • 159
  • 1
  • 13

2 Answers2

0

Use the number pipe here for the correct scenario.

e.g. {{123456789.1234 | number: 9.8-8}}

output: 123,456,789.12340000

See the linkpipe

surendra kumar
  • 1,686
  • 11
  • 15
0

You can use this regex (/\B(?=(\d{3})+(?!\d))/g, ",") after converting your number to string with toString(). I have used it yesterday referenced from one of the SO's old post. Click Here . This is what you are looking for I guess.

Or you can check the angular built in number pipe for that matter.

Wahab Shah
  • 2,066
  • 1
  • 14
  • 19