The angular.isNumber() function in AngularJS is used to determine the parameter inside isNumber function is a number or not. It returns true if the reference is a number otherwise returns false.
Syntax:
angular.isNumber( value );
Parameter value:
- value: It determines whether the entered value is a number or not.
Return Value: It returns a boolean value if the passed value is a number as true, otherwise returns false.
Example: This example illustrates the angular.isNumber() function in AngularJS, to check whether the entered value is a number or not.
HTML
<!DOCTYPE html>
< html >
< script src =
</ script >
< body >
< div ng-app = "app"
ng-controller = "gfgCtrl"
style = "text-align:center" >
< h1 style = "color:green" >GeeksforGeeks</ h1 >
< h2 >angular.isNumber()</ h2 >< br >
< b >Is {{ data1 }} a number?</ b >< br >
< b >{{ data2 }}</ b >
</ div >
< script >
var app = angular.module('app', []);
app.controller('gfgCtrl', function($scope) {
$scope.data1 = 26;
$scope.data2 = angular.isNumber($scope.data1);
});
</ script >
</ body >
</ html >
|
Output:
Example: This example uses angular.isNumber() function to determine whether the given input is a number or not.
HTML
<!DOCTYPE html>
< html >
< head >
< title >angular.isNumber()</ title >
< script src =
"//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js" >
</ script >
</ head >
< body ng-app = "app" style = "text-align:center" >
< h1 style = "color:green" >GeeksforGeeks</ h1 >
< h2 >angular.isNumber()</ h2 >
< div ng-controller = "geek" >
< b >Input1: </ b >
< span >
< code >
123
</ code >
</ span >
< br >
< b >IsNumber: </ b >{{isNumber1}}
< br />< br >< br >
< b >Input2: </ b >
< code >
"geeksforgeeks"
</ code >
< br >
< b >IsNumber:</ b > {{isNumber2}}
</ div >
< script >
var app = angular.module("app", []);
app.controller('geek', ['$scope', function($scope) {
var obj1 = 123;
var obj2 = "geeksforgeeks";
$scope.isNumber1 = angular.isNumber(obj1);
$scope.isNumber2 = angular.isNumber(obj2);
}]);
</ script >
</ body >
</ html >
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
08 Aug, 2022
Like Article
Save Article