网络数据http进行操作

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="../Day08/js/angular.min.js"></script>
<script>
var app = angular.module("myApp",[]);
app.controller("count",function($scope,$http){
$http.get("http://result.eolinker.com/TucCTQueffdc1d1aaa3be05d8c62e9bb5d3e8b495f97cca?uri=hybrid")
.then(function(d){
$scope.persons = d.data;
});

$scope.getAge = function(bir){
var b = new Date(bir).getYear();
var nowb = new Date().getYear();
return nowb-b;
}

$scope.px = "";

$scope.dele = function(id){
var index = 0;
for(var i in $scope.persons){
if($scope.persons[i].id == id){
index = i;
}
}
if(confirm("是否确认删除")){
$scope.persons.splice(index,1);
}
}

$scope.ckAll = function(){
for(var i=0; i<$scope.persons.length; i++){
$scope.persons[i].ck = $scope.flag;
}
}

$scope.deleAll = function(){
var de = 0;
for(var i=0; i<$scope.persons.length; i++){
if($scope.persons[i].ck){
de++;
$scope.persons.splice(i,1);
i--;
}
}
if(de == 0){
alert("请选择")
}
}
});
</script>
<style>
#box{
width: 700px;
height: 500px;
margin: 0 auto;
padding-top: 50px;
text-align: center;
}
table{
width: 600px;
margin: 0 auto;
}
</style>
</head>
<body ng-app="myApp" ng-controller="count">
<h1 ng-show="persons.length == 0">页面无操作数据</h1>
<div id="box" ng-show="persons.length>0">
<input type="text" placeholder="根据姓名模糊查找" ng-model="selname"/>
<input type="text" placeholder="根据部门模糊查找" ng-model="selbname"/>
<select ng-model="px">
<option value="" ng-selected="true">---请选择---</option>
<option value="+birthday">根据年龄排序</option>
<option value="+salary">根据薪资排序</option>
</select>
<input type="button" value="批量删除" ng-click="deleAll()"/>
<table border="1px" cellpadding="0" cellspacing="0">
<tr>
<th><input type="checkbox" ng-model="flag" ng-click="ckAll()"/></th>
    <th>员工姓名</th>
    <th>员工年龄</th>
    <th>员工性别</th>
    <th>员工薪资</th>
    <th>出生日期</th>
    <th>部门名称</th>
    <th>删除</th>
</tr>
<tr ng-repeat="d in persons|filter:{name:selname}|filter:{department:{name:selbname}}|orderBy:px">
<td><input type="checkbox" ng-model="d.ck"/></td>
<td>{{d.name}}</td>
<td>{{getAge(d.birthday)}}</td>
<td>{{d.gender}}</td>
<td>{{d.salary|currency:"¥:"}}</td>
<td>{{d.birthday|date:"yyyy-MM-dd hh:mm:ss"}}</td>
<td>{{d.department.name}}</td>
<td><input type="button" value="删除" ng-click="dele(d.id)"/></td>
</tr>
</table>
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值