AngularJS angular.isObject() Function (original) (raw)

Last Updated : 05 Sep, 2022

The angular.isobject() Function in AngularJS is used to determine if the parameter inside isobject function is an object or not. It returns true if the reference is an object or else false.

Syntax:

angular.isobject(value);

Parameter:

Return Value: It returns true if the value passed is an object else false.

Example 1: This example describes the angular.isObject() Function in AngularJS.

HTML `

angular.isObject()

GeeksforGeeks

angular.isObject()

Input1: obj1 = {"Name": "Binary search"}
isObject: {{isObject1}}


Input2: "geeksforgeeks"
isObject: {{isObject2}}

`

Output:

isobject

Example 2: This example describes the angular.isObject() Function in AngularJS, where both the input values are validated.

HTML `

angular.isObject()

GeeksforGeeks

angular.isObject()

Input 1: obj1 ={{val1}}

isObject: {{isObject2}}

Input 2: obj2 = null;

isObject: {{isObject1}}
<script>
    var app = angular.module('app', []);
    app.controller('geek', [
        '$scope',
        function ($scope) {
            var val2 = null;
            $scope.val1 = [
                { Name: 'Merge Sort' },
                { Name: 'Quick Sort' },
                { Name: 'Selection Sort' },
            ];

            $scope.isObject1 =
                angular.isObject($scope.val2) == true ? 'true.' : 'false';

            $scope.isObject2 =
                angular.isObject($scope.val1) == true ? 'true' : 'false';
        },
    ]);
</script>

`

Output: