How to convert string into a number using AngularJS ? Last Updated : 01 Aug, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to convert a string into a number in AngularJS, along with understanding its implementation through the illustrations. Approach: The parseInt() method is used for converting the string to an integer. We will check whether the string is an integer or not by the isNumber() method.Example 1: In the first example, the string '90' is converted to an integer. HTML <!DOCTYPE HTML> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <script> var myApp = angular.module("app", []); myApp.controller("controller", function ($scope) { $scope.a = '90'; $scope.isNumberA = angular.isNumber($scope.a); $scope.convertToInt = function () { $scope.a = parseInt($scope.a); $scope.isNumberA = angular.isNumber($scope.a); }; }); </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> Convert string into a number in AngularJS </h3> <div ng-app="app"> <div ng-controller="controller"> Value = {{a}} <br><br> <button ng-click='convertToInt()'> Click to convert </button> <br><br>isNumber(value) - {{isNumberA}} </div> </div> </body> </html> Output: Example 2: The 2 strings are added and then converted to an integer and then added again. HTML <!DOCTYPE HTML> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <script> var myApp = angular.module("app", []); myApp.controller("controller", function ($scope) { $scope.a = "10"; $scope.b = "20"; $scope.strToInt = function () { $scope.a = parseInt($scope.a); $scope.b = parseInt($scope.b); }; }); </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> Convert string into a number in AngularJS </h3> <div ng-app="app"> <div ng-controller="controller"> Value-1 = {{a}} <br>Value-2 = {{b}} <br><br> <button ng-click='strToInt()'> Click to convert </button> <br><br>sum - {{a + b}}<br> </div> </div> </body> </html> Output: Comment More infoAdvertise with us Next Article How to use filter within controllers in AngularJS ? P PranchalKatiyar Follow Improve Article Tags : AngularJS HTML-Misc AngularJS-Misc Similar Reads How to concat strings using AngularJS ? In this article, we will see how to concat strings in AngularJS. There are few ways to concat the strings in AngularJS. In this article, we will see 2 of them.Example 1: In the first example, we are using the '+' operator to concat the strings HTML<!DOCTYPE HTML> <html> <head> < 2 min read How to replace a string by another string in AngularJS ? In this article, we will see how to select a string from the text and replace it with another string using AngularJS and will understand it through the illustrations. The replace() method can be used to search the particular character(s), which is getting replaced with a specific character(s) & 2 min read How to encode/decode URL using AngularJS ? In this article, we will see the mechanism to encode/decode URL using AngularJS, along with knowing the different methods available to accomplish the given task, & will understand it through the illustration. A URL specifies a resource and its access protocol.Encode URL: URL Encoding is a way to 3 min read How to use filter within controllers in AngularJS ? In this article, we will see how to use the Filter inside the controller using AngularJS. Filters are used to format the value of an expression and display it to the user. It can be used in HTML Previews, Controllers or Services, and directives. AngularJS facilitates many built-in filters, although, 4 min read Angular PrimeNG Form InputNumber Step Component Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will learn how to use the Form InputNumber Step Component in Angular PrimeNG. We 3 min read How to change the date format using AngularJS ? In this article, we will see how to change the date format using AngularJS. AngularJS provides 2 different ways to change the format of the date. It can be achieved by the following approaches: Using HTML Template BindingUsing JavaScript ControllerHTML Template Binding: In this method, we use the pi 3 min read Like