过滤 与删除

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="js/angular.min.js"></script>
        <script src="js/jquery-1.11.1.js"></script>
        <script>
            var app = angular.module("linrenjiang",[]);
            app.controller("conl",function($scope){
                $scope.stus = [{
                    name:"VIVO X20",
                    cound:3,
                    price:3200
                },{
                    name:"OPPO R9",
                    cound:2,
                    price:2200
                },{
                    name:"华为荣耀",
                    cound:1,
                    price:4200
                }];
                
                $scope.talshow = true;
                $scope.del = function(name){
                    if(window.confirm("确定删除"+name+"吗?")){
                        for(index in $scope.stus){
                            if(name == $scope.stus[index].name){
                                $scope.stus.splice(index,1);
                            }
                        }
                    }
                    if($scope.stus == "" || $scope.stus == null){
                        alert("空了");
                        $scope.talshow = false;
                    }
                };
                $scope.sum = function(){
                    var num = 0;
                    for (var i in $scope.stus){
                        num = num +  $scope.stus[i].cound*$scope.stus[i].price;
                    }
                    return num;
                }
            })
        </script>
    </head>
    <body ng-app="linrenjiang" ng-controller="conl">
        <div id="dahezi">
            <table border="2px" ng-show="talshow">
            
                    <tr>
                    <th>商品名称</th>
                    <th>商品数量</th>
                    <th>商品单价</th>
                    <th>小计</th>
                    <th>操作</th>
                </tr>
                
                <tr ng-repeat="s in stus">
                    <td>{{s.name}}</td>
                    <td>{{s.cound}}</td>
                    <td>{{s.price | currency:"RMB¥:"}}</td>
                    <td>{{s.cound*s.price | currency:"RMB¥:"}}</td>
                    <td><input ng-click="del(s.name)" type="button" value="删除"/></td>
                </tr>
                
                <tr>
                    <td>总金额:{{sum()|currency:"RMB¥:"}}</td>
                </tr>
            </table>
        </div>
    </body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值