Angular Push to an Array or Add
by Rajdeep Chandra
HTML
<div class="wrapper" ng-controller="myController">
<input type="text" ng-model="myName"/>
<input type="text" ng-model="myAdd"/>
<input type="text" ng-model="myPh"/>
<button ng-click="add()">Add More Content
</button>
<table>
<tr ng-repeat= "item in items">
<td>{{item.name}}</td>
<td>{{item.address}}</td>
<td>{{item.contact}}</td>
</tr>
</table>
</div>
JavaScript
var app = angular.module('myApp', []);
app.controller('myController', function($scope)
{
$scope.items = [{ name:'Rajdeep',address:"loken road",contact:982348},
{ name:'Subhodeep',address:"lokenston road",contact:2433423}
];
$scope.add = function(){
$scope.items.push({
name :$scope.myName,
address :$scope.myAdd,
contact :$scope.myPh
});
$scope.myName = "",
$scope.myAdd = "",
$scope.myPh = ""
};
});