33

How can we convert an integer to string in AngularJs, like parseInt() converts string to int. I tried wit $parse, which itself is a wrong approach I think..

1
  • 2
    Integer to string is as simple as calling .toString(); Commented Mar 11, 2014 at 14:28

2 Answers 2

73

.toString() is available, or just add "" to the end of the int

var x = 3,
    toString = x.toString(),
    toConcat = x + "";

Angular is simply JavaScript at the core.

Sign up to request clarification or add additional context in comments.

2 Comments

This answer works. In case if we are reading the x as a variable, it is good to use if ( x != null ) x = x.toString(); Thanks
Yep, ionic 3+ with the .tostring() doesn't seen to work, but the + ""; works like a dream!
0
var x : number = 3;
var st : string = String(x);
console.log(st);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.