2 Example(s) of angular-isFunction


Description :

angular.isFunction will return true for $scope.isFunction2 and false for $scope.isFunction1 because it is object. Lets see the code snippet:


angular-isFunction Example - 1
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Welcome in the AngularJS</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
</head>
<body ng-app="app">
    <div ng-controller="isFunctionController">
        IsFunction: {{isFunction1}}<br />
        IsFunction: {{isFunction2}}
    </div>
</body>
</html>
<script>
    var app = angular.module("app", []);
    app.controller('isFunctionController', ['$scope', function ($scope) {
        var obj = [{ name: "Abc", Address: "West" }, { name: "Xyz", Address: "East" }];
        var Add = function () {
            return null;
        };
        $scope.isFunction1 = angular.isFunction(obj);
        $scope.isFunction2 = angular.isFunction(Add);
    }]);
 
</script>

Output

Description :

angular.isFunction return Boolean value true or false, In our example, it return true because $scope.Add is a function . Lets see the code snippet:


angular-isFunction Example - 2
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Welcome in the AngularJS</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
</head>
<body ng-app="app">
    <div ng-controller="isFunctionController">
        IsFunction: {{isFunction}}
    </div>
</body>
</html>
<script>
    var app = angular.module("app", []);
    app.controller('isFunctionController', ['$scope', function ($scope) {
        $scope.Add = function () {
        };
        $scope.isFunction = angular.isFunction($scope.Add);
    }]);
  
</script>

Output