加减+-操作
程序员文章站
2022-03-04 19:04:34
...
<td><button ng-click="count(+1,$index)">+</button> <input style="width: 30px;" ng-model="s.number" /><button ng-click="count(-1,$index)">-</button> </td>
//加减
$scope.count=function(index,i){
$scope.stus[i].number=$scope.stus[i].number+index;
if($scope.stus[i].number==0){
var f=confirm("您是否将该商品移除购物车?");
if(f==true){
$scope.stus.splice(i,1);
}else if(f=false){
}
}else if($scope.stus.length == 0){
alter('你的购物车为空');
}