I am trying to write a function that enables me to remove an item when the button is clicked. My ng-repeat is below :
<tr ng-repeat="x in myData.List">
<td>{{x.name}}</td>
<td>{{x.item}}</td>
<td><button type="submit" ng-click="delete(x.id)" class="button">Remove</button></td>
</tr>
and my delete function is :
$scope.delete = function (id) {
var index = $scope.myData.List.indexOf(id);
$scope.myData.List.splice(index,1);
};
But problem is that it delete the last object. But I want delete a particular item. what should I do ?