我想用$ http delete从数据库中删除一个产品,但我不能,因为我无法恢复表中元素的id。用angularjs删除查询
代码: 丹斯乐controlleur:
@RequestMapping("/delete")
public boolean deleteProduit(Long Id)
{
produitRepository.delete(Id);
return true;
}
丹斯html页面:
<td >{{p.id}}</td>
<td>{{p.name}}</td>
<td>{{p.price}}</td>
<td>
<a class='btn btn-danger' href='' ng-click='supprim(produits.content)'>
Delete
</a>
丹斯JS:
$scope.supprim = function(data){
$scope.produits.content=data;
var index = $scope.produits.content.indexOf(data);
var result = confirm('Are you sure to delete this product ? ');
if(result===true)
{
alert($scope.produits.content.valueOf(id))
$http.delete("/delete?Id="+$scope.produits.content.id);
$scope.produits.content.splice(index, 1);
}
};
拉页JSON ES t sous cette forme
{“content”:[{“id”:5,“name”:“pk25”,“price”:125.0},{“id”:6,“name”:“ PK25" , “价格”:125.0},{ “ID”:7, “名称”: “PK25”, “价格”:125.0},{ “ID”:8中, “名称”: “PK25”, “价格” :125.0},{ “ID”:9 “名称”: “PK25”, “价格”:125.0}], “总页数”:2 “totalElements”:9 “最后”:假, “尺寸”:5 , “数字”:0, “第一”:真正的 “排序”:空, “numberOfElements”:5}
我需要帮助
欢迎堆栈溢出。我编辑了你的帖子来解决英文问题和格式。 –