购物车的删除



<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        table{
            width: 800px;
            border-collapse: collapse;
            margin: 0 auto;
        }
        th,td{
            border: 1px solid black;
        }
        button{
            background-color: orange;
        }
    </style>
    <script src="angular.js"></script>
    <script>
        var myapp=angular.module("myapp",[]);
        myapp.controller("mycon",function ($scope) {
            $scope.goods=[
                {name:"鼠标",
                     count:1,
                     price:101,
                     zong:101},
                {name:"键盘",
                    count:3,
                    price:601,
                    zong:1833},
                {name:"土机",
                    count:1,
                    price:3001,
                    zong:3001}];


            $scope.zprice=function () {
                $scope.shu=0;
                $scope.num=0;
                for (var i=0;i<$scope.goods.length;i++){
                    $scope.num=$scope.goods[i].zong;
                    $scope.shu=$scope.shu+$scope.num;

                }
                return $scope.shu;
            }
            $scope.del=function ($index) {
                $scope.goods.splice($index, 1);
            }
        })
    </script>
</head>
<body ng-app="myapp" ng-controller="mycon">
    <h4>您的购物车</h4>
    <table>
        <thead>
            <tr>
                <th>商品名称</th>
                <th>数量</th>
                <th>单价</th>
                <th>小计</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody ng-repeat="item in goods">
            <tr>
                <td>{{item.name}}</td>
                <td>{{item.count}}</td>
                <td>{{item.price|currency:"RMB¥"}}</td>
                <td>{{item.zong|currency:"RMB¥"}}</td>
                <td><button ng-click="del($index)">删除</button></td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td></td>
                <td></td>
                <td>总金额</td>
                <td ng-bind="zprice()"></td>
                <td></td>
            </tr>
        </tfoot>
    </table>


</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值