Tutorialsplane

String to number Angularjs


String to number Angularjs โ€“ You can use parseInt to convert string to integer . Here in this tutorial we are going to explain how you can use parseInt() to convert the string into Integer in AngularJs. You can use our online demo try and edit the code online.


Convert String to number Angularjs | String To Int

You can use split() method to split string into array. Here is full example โ€“

Convert String to Int Angularjs Example:




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController"> 


 <button ng-click="convertToInt()">Convert & Add</button><br/>
Before Conversion a + b = {{a + b}}<br/>
After Converting to Int a1 + b1 = {{a1 + b1}}<br/>

</div> 
</div>
  
  

Try it ยป

In the above example we have created a simple example to add to numbers after converting into int in AngularJs.

If you run the above example it will produce the output something like this โ€“