我正在尝试一个删除按钮,它将从表中删除所有选定的数据,我希望我可以同时拼接数组。
HTML
<button class="ui red small labeled icon button right floated" type="button" ng-click="Delete()">Delete</button>
<table class="ui fixed single line celled blue table compact ">
<thead>
<tr>
<th class="width-checkbox"><input type="checkbox" ng-model="selectAll" ng-click="selectedAll()" /></th>
<th class="width-100">Date</th>
<th class="width-120">Qoute no</th>
<th class="width-70">Item</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in Tablelist | paginate:rowsPerPage track by $index" ng-class="ColoringRow(x)">
<td><input type="checkbox" ng-model="x.selected"></td>
<td>{{x.date}}</td>
<td></i>{{x.quote_no}}</td>
<td>{{x.item_no}}</td>
</tr>
</tbody>
</table>
JS
$scope.Delete = function(){
for (var k = 0; k < $scope.Tablelist.length; k++){
if($scope.Tablelist[k].selected == true){
var id = $index;
var docno = $scope.Tablelist[k].quote_no;
$http({
method: 'POST',
url: "api/purchase/purchase.php",
data: {
modul: 'PRICE',
action: 'delete',
docno: docno,
id: id,
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
}
}).then(function(response){
if (response.data == 1){
$scope.Tablelist.splice(id,1)
}else {
console.log("failed delete1");
}
}, function(response){
console.log("failed delete");
})
}
}
}
那么如何从$index
track by $index
角获取var id = $index;
的值
还是有更简单的方法吗?