0

I'm a bit confused here..

I'm trying to create a field with number and binding it into ng-model, but when I input this value

10000000000000000000000

It gets me 1e+22 on the model result, how can I make it as number not this string when I input lot of 0 behind.

Hopefully somebody here giving me 10000000000000000000000 then it should returns 10000000000000000000000 on the ng-model.

https://codepen.io/anon/pen/NaxoXJ

Thank you

fabio.sussetto
  • 6,964
  • 3
  • 25
  • 37
Wawan Brutalx
  • 603
  • 6
  • 15
  • 27

1 Answers1

0

How can I make it as number not this string when I input lot of 0 behind.

It's not a string, it's a number displayed using the scientific notation. Javascript uses this notation for big numbers. For example, in JS, this king of statement is valid :

var i = 1e+22;

Instead of using {{test}} to display your value, call a function to format the number correctly (the result will be a string and not an number).

This post explains how to print a number wihout using the scientific notation.

Updated codepen

Junior Dussouillez
  • 2,327
  • 3
  • 30
  • 39