Update data from table to mongodb Update data from table to mongodb mongoose mongoose

Update data from table to mongodb


Using the Angular JS, we can do all CRUD operation. For your question i have answer,

In HTML

<tr ng-repeat="list in getList">                      <td>{{$index+1}}</td>                    <td>{{list.firstname}}</td>                    <td>{{list.lastname}}</td>                    <td class=" last"><button type="button" class="fa fa-edit btn btn-primary" ng-click="edit($index,list)"></button>                    </td>                  </tr>

In controller,

 $scope.edit=function(idx,list){    $scope.<name of ng-model>=angular.copy(list)    flag=idx;        }

and now in controller where to saving, check the data in save() function, where the list is existing in the table. If yes the call update(), else call add().