<tr ng-repeat="item in cart">
<td>{{item.id}}</td> <td>{{item.name}}</td> <td>{{item.quantity}}</td> <td>{{item.price}}</td> <td>{{item.quantity * item.price}}</td> <td> <button type="button" ng-click="remove(item.id)" class="btn btn-danger">移除</button> </td>
一下是JS部分:
$scope.remove = function (ids) {
var index = -1; //console.log(ids); angular.forEach($scope.cart, function (item,key) { console.log(key); if(item.id===ids){ index =key; } if(index!==-1){ $scope.cart.splice(index,1); } }); }
子衿沉夜
相关分类