上周三代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<style>
			button{background-color: darkorange; color: azure;}
		</style>
		<script type="text/javascript" src="js/angular.js"></script>
		<script>
			var app=angular.module("myApp",[]);
			$scope="Name";
			$scope.desc=0;
			app.controller("myCtrl",function($scope){
				$scope.shuzu=[
					{
						"Bianhao":1234,
						"Name":"ipad",
						"Price":"¥:3.400.00",
						"Kucun":10
					},
					{
						"Bianhao":1244,
						"Name":"aphone",
						"Price":"¥:6.400.00",
						"Kucun":100
					},
					{
						"Bianhao":1334,
						"Name":"mypad",
						"Price":"¥:4.400.00",
						"Kucun":20
					},
					{
						"Bianhao":8234,
						"Name":"zpad",
						"Price":"¥:8.400.00",
						"Kucun":130
					}
				];
				$scope.delete=function($index){
					if($index>=0){
						if(confirm("是否删除此商品")){
							$scope.shuzu.splice($index,1);
						}
					}
				};
				$scope.delete1=function($index){
					if($scope.shuzu.length>=0){
						if(confirm("是否全部删除商品")){
							$scope.shuzu.splice($index);
						}
					}
				};
				var isAllSeclected=true;
				$scope.checkAll=function(){
					for(var i=0;i<$scope.list.length;i++){
						if(isAllSeclected){
							$scope.list[i].chk=true;
						}else{
							$scope.list[i].chk=false;
						}
					}
					isAllSeclected!=isAllSeclected;
				}
			});
		</script>
		<title></title>
	</head>
	<body ng-app="myApp">
		<table ng-controller="myCtrl" border="1" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td colspan="6" align="center"><input type="text" ng-model="query"/><button ng-click="delete1($index)">批量删除</button></td>
			</tr>
			<tr>
				<th><input type="checkbox" ng-model="all" ng-click="checkAll()"></th>
				<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 ng-click="col='Kucun';desc!=desc">商品库存</th>
				<th>删除操作</th>
			</tr>
			<tr ng-repeat="x in shuzu|orderBy:col:desc|filter:query">
				<td><input type="checkbox" name="chk" ng-model="item.chk" ng-checked="all">  </td>
				<td>{{x.Bianhao}}</td>
				<td>{{x.Name}}</td>
				<td>{{x.Price}}</td>
				<td>{{x.Kucun}}</td>
				<td><button ng-click="delete($index)">删除</button></td>
			</tr>
		</table>
	</body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值