<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style type="text/css">
.ss{
background: skyblue;
}
.ss2{
background: gray;
}
</style>
<script src="angular.min.js"></script>
<script type="text/javascript">
var app=angular.module("myapp",[]);
app.controller("myctrl",function($scope,$http){
$http.get("provinces.json").then(function(request){
$scope.province=request.data;
})
$http.get("students.json").then(function(request){
$scope.student=request.data;
})
$scope.aa=function(){
$scope.student.push({
"checked":false,
"name":$scope.name,
"zhuzhi":$scope.p.pro+$scope.p2,
"sex":$scope.sex,
"birthday":$scope.birthday
});
}
$scope.bb=function(i){
$scope.student.splice(i,1);
}
$scope.cc=function(ck,i){
if (ck==true){
$scope.student[i].checked=false;
}else{
$scope.student[i].checked=true;
}
}
$scope.dd=function(){
for (var i=0;i<$scope.student.length;i++) {
if($scope.student[i].checked==true){
$scope.student.splice(i,1);
i--;
}
}
}
$scope.ee=function(){
for(var i=0;i<$scope.student.length;i++){
$scope.student[i].checked=!$scope.student[i].checked;
}
}
});
</script>
<body ng-app="myapp" ng-controller="myctrl">
<div>
姓名:<input name="name" ng-model="name"/> 性别:
<select name="sex" ng-model="sex">
<option value="">--请选择--</option>
<option value="男">男</option>
<option value="女">女</option>
</select>
生日:<input type="date" name="birthday" ng-model="birthday" /> 住址:
<select id="se1" ng-model="p" ng-options="p.pro for p in province">
<option value="">--请选择--</option>
</select>
<select id="se2" ng-model="p2" ng-options="p for p in p.children"><option value="">--请选择--</option></select>
<input type="button" value="添加" id="add" ng-click="aa()" />
</div>
<input type="button" value="全选/反选" id="fx" ng-click="ee()"/>
<input type="button" value="批量删除" id="plsc" ng-click="dd()"/>
<table border="1" cellspacing="0">
<tr ng-class="'ss2'">
<td><input type="checkbox" /></td>
<td>姓名</td>
<td>性别</td>
<td>生日</td>
<td>住址</td>
<td>删除</td>
</tr>
<tr ng-repeat="s in student" ng-class-odd="'ss'" >
<td><input type="checkbox" ng-checked="s.check" ng-model="s.checked" ng-click="cc(s.check,$index)"/></td>
<td>{{s.name}}</td>
<td>{{s.sex}}</td>
<td>{{s.birthday| date:'yyyy-MM-dd'}}</td>
<td>{{s.zhuzhi}}</td>
<td><input type="button" value="删除" ng-click="bb($index)" /></td>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style type="text/css">
.ss{
background: skyblue;
}
.ss2{
background: gray;
}
</style>
<script src="angular.min.js"></script>
<script type="text/javascript">
var app=angular.module("myapp",[]);
app.controller("myctrl",function($scope,$http){
$http.get("provinces.json").then(function(request){
$scope.province=request.data;
})
$http.get("students.json").then(function(request){
$scope.student=request.data;
})
$scope.aa=function(){
$scope.student.push({
"checked":false,
"name":$scope.name,
"zhuzhi":$scope.p.pro+$scope.p2,
"sex":$scope.sex,
"birthday":$scope.birthday
});
}
$scope.bb=function(i){
$scope.student.splice(i,1);
}
$scope.cc=function(ck,i){
if (ck==true){
$scope.student[i].checked=false;
}else{
$scope.student[i].checked=true;
}
}
$scope.dd=function(){
for (var i=0;i<$scope.student.length;i++) {
if($scope.student[i].checked==true){
$scope.student.splice(i,1);
i--;
}
}
}
$scope.ee=function(){
for(var i=0;i<$scope.student.length;i++){
$scope.student[i].checked=!$scope.student[i].checked;
}
}
});
</script>
<body ng-app="myapp" ng-controller="myctrl">
<div>
姓名:<input name="name" ng-model="name"/> 性别:
<select name="sex" ng-model="sex">
<option value="">--请选择--</option>
<option value="男">男</option>
<option value="女">女</option>
</select>
生日:<input type="date" name="birthday" ng-model="birthday" /> 住址:
<select id="se1" ng-model="p" ng-options="p.pro for p in province">
<option value="">--请选择--</option>
</select>
<select id="se2" ng-model="p2" ng-options="p for p in p.children"><option value="">--请选择--</option></select>
<input type="button" value="添加" id="add" ng-click="aa()" />
</div>
<input type="button" value="全选/反选" id="fx" ng-click="ee()"/>
<input type="button" value="批量删除" id="plsc" ng-click="dd()"/>
<table border="1" cellspacing="0">
<tr ng-class="'ss2'">
<td><input type="checkbox" /></td>
<td>姓名</td>
<td>性别</td>
<td>生日</td>
<td>住址</td>
<td>删除</td>
</tr>
<tr ng-repeat="s in student" ng-class-odd="'ss'" >
<td><input type="checkbox" ng-checked="s.check" ng-model="s.checked" ng-click="cc(s.check,$index)"/></td>
<td>{{s.name}}</td>
<td>{{s.sex}}</td>
<td>{{s.birthday| date:'yyyy-MM-dd'}}</td>
<td>{{s.zhuzhi}}</td>
<td><input type="button" value="删除" ng-click="bb($index)" /></td>
</tr>
</table>
</body>
</html>