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