Tutorialsplane

AngularJs Empty Element


AngularJs Empty Element : There are many ways to empty the element’s content. You can use the empty method to remove the content of the element. Here in this tutorial we are going to use the .empty() method to empty the element. You can use our online editor to try and edit the code online.


AngularJs Empty Element Example

You can empty element simply as below –

JavaScript Part

JavaScript Part Contains the following script –

AngularJs Empty Element Example:

 

Html Part

Html Part Contains the following html-

AngularJs Empty Element Example:

<div ng-app="myApp">  
<div ng-controller="myController">  
 
<div id="myDiv" class="amp-wp-inline-f5a2fab0255e0e9220163ba8089500d3">
<h3>Heading</h3>
<p>Hello World!</p>
</div>
</div> 

</div>

Complete Part

Let us combine the both JavaScript and Html Part –

AngularJs Empty Element Example:




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController">  
 
<div id="myDiv" class="amp-wp-inline-f5a2fab0255e0e9220163ba8089500d3">
<h3>Heading</h3>
<p>Hello World!</p>
</div>
</div> 

  
      


</div>

Try it »

If you run the above example it will produce output something like this and if you click on the empty button it will clear the div content as below –