卤蛋的二周考

<!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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值