Open In App
Related Articles

AngularJS angular.isObject() Function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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:

  • value: This parameter value validates whether the entered value is an object or not.

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

<!DOCTYPE html>
<html>
  
<head>
    <script src=
"//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js">
    </script>
    <title>angular.isObject()</title>
</head>
  
<body ng-app="app" style="text-align:center">
    <h1 style="color:green">GeeksforGeeks</h1>
    <h2>angular.isObject()</h2>
    <div ng-controller="geek"
       <b>Input1: </b
       <span>
            <code>
                obj1 = {"Name": "Binary search"}
            </code>
        </span>
        <br>
        <b>isObject: </b>{{isObject1}}
        <br /><br><br
        <b>Input2: </b
        <code>
            "geeksforgeeks"
        </code>
        <br
        <b>isObject:</b> {{isObject2}} 
    </div>
    <script>
        var app = angular.module("app", []);
        app.controller('geek', ['$scope', function($scope) {
            var obj1 = {
                "Name": "Binary search"
            };
            var obj2 = "geeksforgeeks";
            $scope.isObject1 = angular.isObject(obj1);
            $scope.isObject2 = angular.isObject(obj2);
        }]);
    </script>
</body>
</html>

                    

Output:

isobject

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

HTML

<!DOCTYPE html>
<html>
  
<head>
    <title>angular.isObject()</title>
    <script src=
    </script>
</head>
  
<body ng-app="app" style="text-align: center">
    <h1 style="color: green">GeeksforGeeks</h1>
    <h2>angular.isObject()</h2>
    <div ng-controller="geek">
        <b>Input 1: </b>
        <span>
            <code> obj1 ={{val1}} </code>
        </span>
        <br /><br />
        <b> isObject: </b>{{isObject2}} 
        <br /><br />
        <b>Input 2:</b>
        <span>
            <code> obj2 = null; </code>
        </span>
        <br /><br />
        <b>isObject: </b> {{isObject1}}
    </div>
  
    <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>
</body>
</html>

                    

Output:

 



Last Updated : 05 Sep, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads