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:

<!DOCTYPE html>
<html lang="en">
 <script src="//"></script>
var myApp = angular.module("myApp", []);
 myApp.controller("myController", function($scope) {
 $scope.a = '90';
 $scope.b = '10';
 $scope.a1 = '';
 $scope.b1 = '';
 $scope.convertToInt = function() {	 
	 $scope.a1 = parseInt($scope.a);
     $scope.b1 = parseInt($scope.b);	 
<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>


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 –

String to number Angularjs


Add Comment

📖 Read More