Here is my JS:
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.items = [
{
"name": "john",
"params": {
"age": 22,
"weight": 66
}
},
{
"name": "eva",
"params": {
"age": 19,
"weight": 54
}
},
{
"name": "jeremy",
"params": {
"age": 17,
"weight": 75
}
}
]
$scope.add = function(name, age, weight) {
$scope.items.push({"name" : name, "params" : {"age" : age, "weight" : weight}});
console.log($scope.items);
}
});
My HTML:
<div ng-repeat="item in items">
<p>{{item.name}}</p>
<input class="form-control" name="type" placeholder="name" ng-model="name">
<br />
<ul>
<li ng-repeat="(name, param) in item.params">{{name}} : {{param}}</li>
<input class="form-control" placeholder="age" ng-model="age">
<input class="form-control" placeholder="weight" ng-model="weight">
<button class="btn btn-clear" type="button" ng-click="add(name, age, weight)">Update</button>
</ul>
</div>
I want to edit array, and push this array in place of editing array, not add like new array. Here is my plunker : http://plnkr.co/edit/ewyzJWJOdNOKoSxWacNX?p=preview Thanks for answers in advance!