购物车(排序,删除,查询)

 <!DOCTYPE html>
 <html>
 <head>
 <meta charset="utf-8" />
 <title></title>
 <script src="js/angular.js"></script>
 <script>
 var app=angular.module("myapp",[])
 app.controller("myctrl",function($scope){
 $scope.arr=[
 {"bianhao":8,"name":"iphone1","price":6767},
 {"bianhao":5,"name":"iphone2","price":6733},
 {"bianhao":34,"name":"iphone3","price":6757},
 {"bianhao":2,"name":"iphone4","price":65567},
 {"bianhao":56,"name":"iphone5","price":6367},
 ]
 $scope.del=function(newname){
 if(newname!="")
 { for(index in $scope.arr)
 {
 var na=$scope.arr[index].name
 if(na==newname)
 {
 $scope.arr.splice(index,1)
 }
 }
  
 }
  
  
 }
 $scope.delall=function($index){
 $scope.arr.splice($index)
  
 }
 $scope.col="name"
 $scope.desc=0
 })
  
  
 </script>
 <style>
 tr{ text-align: center;}
 </style>
 </head>
 <body ng-app="myapp" ng-controller="myctrl">
 <center>
 <input type="text" placeholder="产品名称" id="select" ng-model="selt"/>
 <font ng-click="delall($index)">全部删除</font>
 <table cellpadding="0" border="1px" cellspacing="0" width="600">
 <tr>
 <th ng-click="col='bianhao';desc=!desc">产品编号</th>
 <th ng-click="col='name';desc=!desc">产品名称</th>
 <th ng-click="col='price';desc=!desc">产品价格</th>
 <th><font>操作</font></th>
 </tr>
 <tr ng-repeat="a in arr|orderBy:col:desc|filter:selt">
 <td>{{a.bianhao}}</td>
 <td>{{a.name}}</td>
 <td>{{a.price|currency:"(RMB)"}}</td>
 <td><font ng-click="del(a.name)">删除</font></td>
 </tr>
 </table>
 </center>
 </body>
 </html>
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值