我想从网格中删除行。在一个foreach函数中,我需要使$ http.delete调用从数据库中删除。以下是我在另一个类似问题的帮助下编写的代码。请告知最新错误。它达到$ http.delete,但没有打电话。
var promises = [];
angular.forEach($scope.gridApi.selection.getSelectedRows(),
function (data, index)
{ $scope.gridOptions.data.splice($scope.gridOptions.data.lastIndexOf(data), 1);
promises.push($scope.deleteRow(data._id));
}
);
$q.all(promises).then(
function success(){alert("Delete successful");},
function failure(err){alert("Error in deletion");}
);
$scope.deleteRow = function(rowId)
{
return $http.delete('http://localhost:8080/deleterecords/' + data._id);
}
什么是错误?您可以提供的任何代码片段? –
您是否在浏览器开发人员工具的Javascript控制台中查找错误? –
感谢Johannes!..刚接触javascript调试,是的,因为你建议我检查浏览器开发工具,并且在控制台选项卡中有错误... as squaleLis below below,data error for data variable! – higujral