angular.js 购物车

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>week</title>
        <script type="text/javascript" src="js/angular.js" ></script>
        <script>
            var app  = angular.module("myapp",[]);
                app.controller("myctrl",function($scope){
                         $scope.goods = [
                         {"id":80,"name":"iphone","price":5400,},
                         {"id":1200,"name":"ipad mini","price":2200,},
                         {"id":500,"name":"ipad air","price":2340,},
                         {"id":29,"name":"ipad","price":1420,},
                         {"id":910,"name":"imac","price":15400,}
                         ];
                         
                         // 
                         $scope.bold = "bold";
                        $scope.title = 'name';  
                        $scope.desc = 0;  
                        $scope.key = ''; 
                         
                         //删除
                        $scope.deletes =function(name){
                            
                             var p;
                            for( index in     $scope.goods){
                                 p = $scope.goods[index];
                                if( p.name == name){
                                    $scope.goods.splice(index,1);
                                }
                                 
                            }
                            
                        };
                        $scope.delall =function(){
                            //alert("sasd");
                            $scope.goods.splice($scope.goods);
                        };
                        
                         $scope.togg =function(tit){
                             $scope.title = tit;  
                             $scope.desc = !$scope.desc;  
                        };
                });
        </script>
    </head>
    <body ng-app="myapp" ng-controller="myctrl">
        <center>
        <table cellpadding="10" cellspacing="0" border="1">
            <tr>
                 <th><input class="form-control" type="text" ng-model="key" placeholder="请输入产品名称关键字"/></th>
                 <th colspan="3" align="left" ng-click="delall()">全部删除</th>    
             </tr>
             <tr  >
                 <th ng-click="togg('id')" ng-click="ss()">产品编号▼</th>
                 <th ng-click="togg('name')">产品名称▼</th>
                 <th ng-click="togg('price')">产品价格▼</th>
                 <th>删除</th>
             </tr>
              <tr ng-repeat="x in goods | filter: {name: key} | orderBy: title : desc">
                 <td>{{x.id}}</td>
                 <td>{{x.name}}</td>
                 <td>{{x.price | currency:"(RMB)"}}</td>
                 <td><span ng-click="deletes(x.name)">删除</span></td>
             </tr>
        </table>
        </center>
    </body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值