<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/angular.min.js">
</script>
<script type="text/javascript">
var app = angular.module("spx", []);
app.controller("con", function($scope) {
$scope.jh = [{
name: '石争鑫',
age: 19,
birthday: new Date('1999-2-5'),
sex: '男',
cs: '河北-邯郸'
},
{
name: '石争鑫2',
age: 19,
birthday: new Date('1999-2-5'),
sex: '男',
cs: '河北-邯郸'
}
];
$scope.qx = function() {
var f = $scope.yi;
for(var i in $scope.jh) {
$scope.jh[i].ck = f
}
};
//删除
$scope.sc = function(s) {
var sf= confirm("是否删除");
if(sf){
$scope.jh.splice(s, 1);}
};
//批量删除
$scope.ps=function(){
for(var ii=0;ii<$scope.jh.length;ii++)
{
if($scope.jh[ii].ck)
{
$scope.jh.splice(ii,1);
ii--;
}
}
};
//添加
$scope.bc=function(){
var name=$scope.uname;
var age=$scope.age;
var sex=$scope.sex;
var birthday=$scope.birthday;
var cs=$scope.pro+'-'+$scope.city;
$scope.jh.push({name: name,
age: age,
birthday: new Date(birthday),
sex: sex,
cs: cs});
}
});
</script>
</head>
<body ng-app="spx" ng-controller="con">
<form >
姓名:<input ng-model="uname" />
年龄:<input ng-model="age" />
性别:<select ng-model="sex">
<option value="男">男</option>
<option value="女">女</option>
</select>
生日:<input type="date" ng-model="birthday" />
住址:<input ng-model="pro" /> <input ng-model="city" />
<button ng-click="bc()">保存</button>
</form>
<button ng-click="ps()">批量删除</button>
<table border="1" cellspacing="" cellpadding="">
<tr>
<th><input type="checkbox" ng-model="yi" ng-click="qx()" /></th>
<th>姓名</th>
<th>年龄</th>
<th>生日</th>
<th>性别</th>
<th>城市</th>
<th>操作</th>
</tr>
<tr ng-repeat="d in jh |orderBy:'-age'">
<td><input type="checkbox" ng-model="d.ck" /></td>
<td>{{d.name}}</td>
<td>{{d.age}}</td>
<td>{{d.birthday|date:"yyyy-MM-dd"}}</td>
<td>{{d.sex}}</td>
<td>{{d.cs}}</td>
<td>
<button ng-click="sc($index)">删除</button>
</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/angular.min.js">
</script>
<script type="text/javascript">
var app = angular.module("spx", []);
app.controller("con", function($scope) {
$scope.jh = [{
name: '石争鑫',
age: 19,
birthday: new Date('1999-2-5'),
sex: '男',
cs: '河北-邯郸'
},
{
name: '石争鑫2',
age: 19,
birthday: new Date('1999-2-5'),
sex: '男',
cs: '河北-邯郸'
}
];
$scope.qx = function() {
var f = $scope.yi;
for(var i in $scope.jh) {
$scope.jh[i].ck = f
}
};
//删除
$scope.sc = function(s) {
var sf= confirm("是否删除");
if(sf){
$scope.jh.splice(s, 1);}
};
//批量删除
$scope.ps=function(){
for(var ii=0;ii<$scope.jh.length;ii++)
{
if($scope.jh[ii].ck)
{
$scope.jh.splice(ii,1);
ii--;
}
}
};
//添加
$scope.bc=function(){
var name=$scope.uname;
var age=$scope.age;
var sex=$scope.sex;
var birthday=$scope.birthday;
var cs=$scope.pro+'-'+$scope.city;
$scope.jh.push({name: name,
age: age,
birthday: new Date(birthday),
sex: sex,
cs: cs});
}
});
</script>
</head>
<body ng-app="spx" ng-controller="con">
<form >
姓名:<input ng-model="uname" />
年龄:<input ng-model="age" />
性别:<select ng-model="sex">
<option value="男">男</option>
<option value="女">女</option>
</select>
生日:<input type="date" ng-model="birthday" />
住址:<input ng-model="pro" /> <input ng-model="city" />
<button ng-click="bc()">保存</button>
</form>
<button ng-click="ps()">批量删除</button>
<table border="1" cellspacing="" cellpadding="">
<tr>
<th><input type="checkbox" ng-model="yi" ng-click="qx()" /></th>
<th>姓名</th>
<th>年龄</th>
<th>生日</th>
<th>性别</th>
<th>城市</th>
<th>操作</th>
</tr>
<tr ng-repeat="d in jh |orderBy:'-age'">
<td><input type="checkbox" ng-model="d.ck" /></td>
<td>{{d.name}}</td>
<td>{{d.age}}</td>
<td>{{d.birthday|date:"yyyy-MM-dd"}}</td>
<td>{{d.sex}}</td>
<td>{{d.cs}}</td>
<td>
<button ng-click="sc($index)">删除</button>
</td>
</tr>
</table>
</body>
</html>