D
D
des1roer2016-04-15 13:33:06
Angular
des1roer, 2016-04-15 13:33:06

Angular isNumber?

you can of course use

function isNumeric(n) {
    return !isNaN(parseFloat(n)) && isFinite(n);
}

but here
myApp.controller('DoubleController', ['$scope', function ($scope) {
        $scope.double = function (value) {
            return (angular.isNumber(value)) ? value * 2 : null;
        };
    }]);

never works.
or am I using it wrong? https://docs.angularjs.org/api/ng/function/angular...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Belokopytov, 2016-04-15
@belokopytoff

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 question

Ask a Question

731 491 924 answers to any question