Tutorialsplane

AngularJs add item to Array


AngularJs add item to Array- It is very simple to push a value in AngularJs Array . push() method is used to add(push) an element in AngularJs array. Here in this tutorial we are going to explain how you can use push() to insert an element in AngularJs Array. You can use our online demo try and edit the code online.


AngularJs add item to Array | Example

You can use push() method to add an element in an array. Here is full example –

AngularJs add item to Array | Example:




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController"> 
 
 Enter a value and click "Push" Button to insert in array.
 <br/>
 <button ng-click="pushInArray()">Push</button><br/>
 Array = {{exampleArray}}<br/>

</div> 
</div>
  
  

Try it »

In the above example we have created a simple example to add elements in array in AngularJs.

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