Open In App

AngularJS angular.isElement() Function

Last Updated : 05 Sep, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The angular.isElement() Function in AngularJS is used to determine if the parameter inside isElement function is a HTML DOM element or not. It returns true if the reference is a DOM element or else false. 

Syntax:

angular.isElement(value)

Parameter:

  • value: It is used to validate whether the passed argument is an HTML DOM element or not.

Return Value: It returns a boolean value, i.e, returns true if the value passed is an HTML DOM element or else returns false

Example: This example illustrates the use of the angular.isElement() 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.isElement()</title>
</head>
  
<body ng-app="testApp" style="text-align:center">
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
    <h2>angular.isElement()</h2>
    <div ng-controller="geek"><br>
    <b>Input1:</b>
        <code>
            {'destroy': true, 'create': false}
        </code>
        <br>
        <b>isElement:</b> {{ isElement1 }}
        <br><br><br>
        <b>Input2:</b
        <code>
            window.getElementByID('myButton')
        </code>
        <br>
        <b>isElement:</b> {{ isElement2 }}
        <br><br>
        <button id="myButton"> Button</button>
    </div>
    <script>
        var app = angular.module('testApp', []);
        app.controller('geek', function($scope) {
            $scope.obj1 = {
                'destroy': true,
                'create': false
            };
            $scope.obj2 = document.getElementById('myButton');
            $scope.isElement1 = angular.isElement($scope.obj1);
            $scope.isElement2 = angular.isElement($scope.obj2);
        });
    </script>
</body>
</html>


Output:

isElement

Example 2: This is another example that describes the angular.isElement() Function in AngularJS, by checking both the input values whether it is HTML DOM element or not.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src=
"//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js">
    </script>
    <title> angular.isElement() </title>
</head>
  
<body ng-app="testApp" style="text-align:center">
    <h1 style="color:green">GeeksforGeeks</h1>
    <h2>angular.isElement()</h2>
    <div ng-controller="geek"><br
        <b>Input1:</b>
        <code>
            ["DSA", "Algo", "Web Tech"]
        </code><br
        <b>isElement:</b> {{ isElement1 }}
        <br><br><br>
        <b>Input2:</b>
        <code>
            window.getElementByID('myDiv')
        </code><br
        <b>isElement:</b> {{ isElement2 }}
        <br><br>
        <div id="myDiv">Div element</div>
    </div>
    <script>
        var app = angular.module('testApp', []);
        app.controller('geek', function($scope) {
            $scope.obj1 = ["DSA", "Algo", "Web Tech"];
            $scope.obj2 = document.getElementsByClassName('division');
            $scope.isElement1 = angular.isElement($scope.obj1);
            $scope.isElement2 = angular.isElement($scope.obj2);
        });
    </script>
</body>
</html>


Output:

 



Previous Article
Next Article

Similar Reads

Underscore.js _.isElement() Function
The _.isElement() function: is used to check whether the element is a document object model or not. A document object model is the way javascript sees the data of the containing pages. The Cascading style sheet (CSS) and javascript (JS) interact with Document object model (DOM). Syntax:_.isElement(object) Parameters:It takes only one argument which
3 min read
ReactJS isElement() Method
React.js library is all about splitting the app into several components. Each Component has its own lifecycle. React provides us some in-built methods that we can override at particular stages in the life-cycle of the component. In this article, we will know how to use isElement() method. The isElement() method returns true if an element is any rea
2 min read
Lodash _.isElement() Method
Lodash _.isElement() method is used to check whether the specified value is a DOM element or not. Syntax:_.isElement(value);Parameters: value: This parameter holds the value to be checked.Return Value: This method returns a boolean value true if the specified value is a DOM element, else false. Example 1: In this example, it is returning false as t
1 min read
AngularJS angular.isObject() Function
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
2 min read
AngularJS angular.isUndefined() Function
The angular.isUndefined() function in AngularJS is used to determine the value inside isUndefined function is undefined or not. It returns true if the reference is undefined otherwise returns false. Syntax: angular.isUndefined( value ) Parameter value: value: It is used to reference the value to check whether the value is defined or undefined.Retur
2 min read
AngularJS angular.isNumber() Function
The angular.isNumber() function in AngularJS is used to determine the parameter inside isNumber function is a number or not. It returns true if the reference is a number otherwise returns false. Syntax: angular.isNumber( value );Parameter value: value: It determines whether the entered value is a number or not.Return Value: It returns a boolean val
2 min read
AngularJS | angular.isString() Function
The angular.isString() function in AngularJS is used to determine the parameter inside isString function is a string or not. It returns true if the reference is a string otherwise returns false. Syntax: angular.isString( value ) Return Value: It returns true if the value passed is a string otherwise return false. Example: This example uses angular.
1 min read
AngularJS angular.isDefined() Function
The angular.isDefined() function in AngularJS is used to determine the value inside isDefined function is defined or not. It returns true if the reference is defined otherwise returns false. Syntax: angular.isDefined( value );Parameter value: value: This parameter is a reference to check whether the entered value is defined or not.Return Value: It
2 min read
AngularJS angular.isDate() Function
The angular.isDate() function in AngularJS is used to determine whether the value of the date is valid or not. It returns true if the reference is a date else false. Syntax: angular.isDate( value );Parameters: This function accepts a single parameter: value: It stores the data object. Return Value: It returns true if the value passed is a date else
2 min read
AngularJS angular.toJson() Function
The angular.toJson() Function in AngularJS is used to serialize the javascript object into a JSON - formatted string. It takes the javascript object and returns a JSON string. The angular.toJson() function in AngularJS is capable of handling circular references in JavaScript objects. Circular references occur when an object refers to itself or when
2 min read