京东的清理

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/angular.min.js"></script>
<script>
 angular.module("cg",[]).controller("tr",function($scope,$http){
  $http.get("http://result.eolinker.com/rR1VBtT56a6bb220c10b3d44b65b4787a8aec03c4ec32ce?uri=ThirdTest")
   .success(function(ol){
    $scope.datas=ol;
      //清空
       $scope.qk=function(){
                            for(var i=0;i<$scope.datas.length;i++){
                            if($scope.datas[i].cli){
                              $scope.datas.splice(i,1);
                              i--;
                            }
                            }
                           }
     
   })
})
</script>

</head>
<body ng-app="cg" ng-controller="tr">
  <h1 align="center">我的购物车详情</h1>
  <!--清空定义-->
  <span ng-if="datas.length==0">购物车<a href="#">去逛商城</a></span>
<table border="1"> 
     <!--清空定义-->
     <button ng-click="qk()">清空购物车</button><br/>
<tr>
<td>商品编号</td>
<td>商品名称</td>
<td>商品数量</td>
<td>商品单价</td>
<td>价格小计</td>
<td>操作</td>

</tr>
<tr ng-repeat="x in datas" style="background: #4CD964;"> <!--颜色定义-->
     <!--全选-->
<td><input type="checkbox" ng-model="x.cli"></td>
<td>{{x.id}}</td>
<td>{{x.name}}</td>
<td >{{x.price}}</td>
<td> 
<!--加减符号-->
<button ng-click="jian(x)">-</button>
<input type="number" ng-model="x.number" style="width:30px;">
<button ng-click="jia(x)">+</button></td>
<!--加减符号-->
</td>
<td>{{x.price*x.number|currency:"¥"}}</td>

</tr>



</table>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_41880256/article/details/79836309