I was created table data and edit button and i am getting problem when i was trying to add edit data to specific row.
Here my plunkr :- http://plnkr.co/edit/QKz7nu458i8Il4OLmAyw?p=preview
Here HTML page
<table class="table table-bordered">
<thead>
<tr>
<th><input type='checkbox' ng-modal='isall' ng-click='selectallrows()'></th>
<th>ID</th>
<th>Name</th>
<th>EDIT</th>
</tr>
</thead>
<tbody>
<tr ng-repeat='p in person' ng-class="{'success':tableselection[$index]}">
<td><input type='checkbox' ng-model='tableselection[$index]'></td>
<td>{{p.id}}</td>
<td>{{p.name}}</td>
<td><button class='btn btn-primary' ng-click='edit(p.id)'><span class="glyphicon glyphicon-pencil"></span>Edit</button></td>
</tr>
</tbody>
</table>
<div ng-show='editabledata'>
<form role='form' class='form-horizontal'>
<div class='form-group'>
<label>Id :-</label>
<input type='text' ng-model='pid' class='from-group col-sm-2'></div>
<div class='form-group'>
<label>Name:-</label>
<input type='text' ng-model='pname' class='from-group col-sm-2'>
</div>
<button class='btn btn-primary' ng-click='saveeditdata(pid)'>Save</button>
<button clas='btn btn-primary' ng-click='canceleditdata()'>Cancel</button>
</form>
</div>
Here my .js
$scope.person=[
{id:1,name:'devendher'},
{id:2,name:'Macha'},
{id:3,name:'Macha devendher'}
];
$scope.editabledata=false;
$scope.edit=function(id){
$scope.editabledata=true;
for(i=0;i<$scope.person.length;i++){
if($scope.person[i].id==id)
{
$scope.pid=$scope.person[i].id;
$scope.pname=$scope.person[i].name;
}
}
}
$scope.saveeditdata=function(id){
for(i=0;i<$scope.person.length;i++){
if($scope.person[i].id==id){
$scope.person[i].push({'id':$scope.pid,'name':$scope.pname})
}
}
}
i got error " $scope.person[i].push " is not a function Is there any alternate way to add data to specific index of array?