AngularJS – angular.element() function

The angular.element() method wraps the raw DOM element or the HTML string as a jQuery element. If jQuery is available or imported, angular.element is an alias for the jQuery function, else this method delegates to AngularJS’s built-in subset of jQuery called jQueryLite or jqLite.

Syntax

angular.element(element)

Example − Wrapping the DOM element using angular.element()

Create a file "element.html" in your Angular project directory and copy-paste the following code snippet.


   
      angular.element()

      
   

   
      

         Welcome to Tutorials Point      

     

         AngularJS | angular.element()      

     
                             
         
         You typed: {{value}}      
           

Output

To run the above code, just go to your file and run it as a normal HTML file. You will see the following output on the browser window.

Example 2

Create a file "element.html" in your Angular project directory and copy-paste the following code snippet.


   
      angular.element()

      
   

   
      

         Welcome to Tutorials Point      

     

         angular.element()      

     
         
            {{name}}          
     
           

Output

To run the above code, just go to your file and run it as a normal HTML file. You will see the following output on the browser window.

Updated on: 2021-10-08T13:16:08+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements