安卓4 网页增删查

//网页的增删 

<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />

<script src="js/angular.min.js" type="text/javascript"></script>
<script src="js/jquery-3.2.1.min.js" type="text/javascript"></script>
<title></title>
</head>
<body ng-app="myapp" ng-controller="myctrl">
<h2>您的购物车</h2>
<input type="text" name="" id="" value="" title="按商品名查询" ng-model="qname"/>


<table align="center" border="1px" cellspacing="0px" style="width: 60%;">
<tr>
<td>商品编号</td>
<td>商品名称</td>
<td>商品数量</td>
<td>商品单价</td>
<td>商品总价</td>
<td>商品操作</td>
</tr>


<tr ng-repeat="x in datas | filter:{name:sel} |orderBy:selOrder">
<td>{{x.id}}</td>
<td>{{x.sname}}</td>
<td><input type="number" ng-model="x.num" />  </td>
<td>{{x.price | currency:"¥"}}</td>
<td>{{x.num*x.price | currency:"¥"}}</td>
<td><button ng-click="remove($index)">删除</button></td>
</tr>


</table>


<p>商品总数是:{{getTotal()|currency:"RMB ¥"}}</p>


<script type="text/javascript">
//1.获取Angular模块
var app=angular.module("myapp",[]);
//2.设置控制器
app.controller("myctrl",function($scope){
//初使化为true
//$scope.isShow=false;
//初使化shops
$scope.datas=[{id:"001",sname:"百世",num:5,price:50},
 {id:"004",sname:"美年达",num:1,price:200},
 {id:"002",sname:"雪碧",num:4,price:30},
 {id:"003",sname:"黑加仑",num:7,price:500}];
$scope.ob="";
  $scope.isClick=true;
  
  $scope.oo=function(){
  if($scope.isClick){
  $scope.ob="id";
  $scope.isClick=false;
  }else{
  $scope.ob="-id";
  $scope.isClick=true;
  }
  }
  $scope.jj=function(){
  if($scope.isClick){
  $scope.ob="num";
  $scope.isClick=false;
  }else{
  $scope.ob="-num";
  $scope.isClick=true;
  }
  }
  $scope.remove=function(index){
  $scope.datas.splice(index,1);
  }


//定义方法,计算总的商品价钱
$scope.getTotal=function(){
var total=0;
for (var i = 0; i < $scope.datas.length; i++) {
//进行累加计算
total=total+($scope.datas[i].num*$scope.datas[i].price);
}
return total;
}
});
</script>

</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值