Tutorialsplane

AngularJs Remove Item From Array


AngularJs Remove Item From Array : You can use array splice method to remove an item from AngularJs array. Here in this tutorial we are going to explain how to remove an item from AngularJs Array. You can also use our online tool to run and edit the code.


AngularJs Remove Item From Array

To Remove an item from AngularJs we first need to find the item index then use splice method to remove the item by the index. Here is an example of removing an item from an array.

JavaScript Part –

JavaScript Part Contains the following script –

AngularJs Delete Item or Object From Array:

 

Html Part-

Html Part Contains the following html –

AngularJs Delete Item or Object From Array Example:

<div ng-app="myApp">  
<div ng-controller="myController">  
<p>Remove b from array = {{myArray}}</p>
 
</div> 

</div>

Complete Example-

Now let us combine both javascript and html parts. Here is the complete example –

AngularJs Delete Item or Object From Array:

 




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController">  
<p>Remove b from array = {{myArray}}</p>
 
</div> 

  
      


</div>

Try it »

If you run the above example it will produce output something like this –

If you click on the “remove b” button it will remove b from the above array.