<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<script type="text/javascript" src="js/angular.js" ></script> | |
<script> | |
var app = angular.module("myApp",[]); | |
app.controller("myCtrl",function($scope){ | |
$scope.student = [{ | |
"name":"张三", | |
"weizi":"控球后卫", | |
"qiuhao":11, | |
"piaoshu":999 | |
},{ | |
"name":"李四", | |
"weizi":"大前锋", | |
"qiuhao":21, | |
"piaoshu":888 | |
},{ | |
"name":"王五", | |
"weizi":"小前锋", | |
"qiuhao":23, | |
"piaoshu":777 | |
},{ | |
"name":"赵六", | |
"weizi":"中锋", | |
"qiuhao":10, | |
"piaoshu":666 | |
}] | |
$scope.px = ""; | |
$scope.sc = function(name){ | |
if (window.confirm("确定删除?")) { | |
for (a in $scope.student) { | |
if (name == $scope.student[a].name) { | |
$scope.student.splice(a,1); | |
} | |
} | |
} | |
} | |
}); | |
</script> | |
</head> | |
<body ng-app="myApp" ng-controller="myCtrl"> | |
查询:<input type="text" ng-model="cx"/> | |
排序:<select ng-model="px"> | |
<option value="">排序方法</option>s | |
<option value="piaoshu">票数正序</option> | |
<option value="-piaoshu">票数逆序</option> | |
</select><br /><br /> | |
<table border="1px solide blue" cellpadding="10" cellspacing="0"> | |
<tr> | |
<th>姓名</th> | |
<th>位置</th> | |
<th>球号</th> | |
<th>票数</th> | |
</tr> | |
<tr ng-repeat="p in student | filter:{name:cx} | orderBy:px"> | |
<td>{{p.name}}</td> | |
<td>{{p.weizi}}</td> | |
<td>{{p.qiuhao}}</td> | |
<td>{{p.piaoshu}}</td> | |
<td><button ng-click="sc(p.name)">删除</button></td> | |
</tr> | |
</table><br /> | |
<button ng-click="showForm()">添加商品</button><br /><br /> | |
</body> | |
</html> | |
购物车1
最新推荐文章于 2021-07-21 16:41:42 发布