Answer the question
In order to leave comments, you need to log in
Angular isNumber?
you can of course use
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
myApp.controller('DoubleController', ['$scope', function ($scope) {
$scope.double = function (value) {
return (angular.isNumber(value)) ? value * 2 : null;
};
}]);
Answer the question
In order to leave comments, you need to log in
angular.isNumber returns true if the passed argument passes the following test:
typeof (value) === 'number'
You are most likely passing a string or some other type of data to the function.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question