代码如下:
<!DOCTYPEhtml>
<html>
<head>
<metacharset="UTF-8">
<title>增删改查</title>
<scriptsrc="js/angular.min.js"></script>
<script>
varapp=angular.module("anan",[]);
app.controller("enen",function($scope){
$scope.user=[{
ck:false,
id:1,
name:'李1',
pwd:123456,
level:3
},{
ck:false,
id:2,
name:'李2',
pwd:123456,
level:1
},{
ck:false,
id:3,
name:'李3',
pwd:123456,
level:3
},{
ck:false,
id:4,
name:'李4',
pwd:123456,
level:1
},{
ck:false,
id:5,
name:'李5',
pwd:123456,
level:2
},{ck:false,
id:6,
name:'李6',
pwd:123456,
level:3
},{
ck:false,
id:7,
name:'李7',
pwd:123456,
level:2
},{
ck:false,
id:8,
name:'李8',
pwd:123456,
level:1
},{
ck:false,
id:9,
name:'李9',
pwd:123456,
level:2
},{
ck:false,
id:10,
name:'李10',
pwd:123456,
level:1
}];
$scope.ckAll=function(){
for(vari=0;i<$scope.user.length;i++){
$scope.user[i].ck=$scope.flag;
}
}
$scope.delso=function(){
varshu=0;
for(vari=0;i<$scope.user.length;i++){
if($scope.user[i].ck){
$scope.user.splice(i,1);
shu++;
i--;
}
}
}
$scope.insert=function(m){
vargood={ck:false,id:$scope.tid,name:$scope.tname,pwd:$scope.tpwd,level:$scope.tlevel};
$scope.user.push(good);
}
})
</script>
<styletype="text/css">
#cll:nth-child(even){
background-color:lightseagreen;
}
#cll:nth-child(odd){
background-color:#C9C994;
}
</style>
</head>
<bodyng-app="anan"ng-controller="enen">
<divstyle="margin:0auto;height:800px;width:1000px;border:1pxsolidgreenyellow;">
<inputplaceholder="用户名搜索"ng-model="souname"/>
<selectng-model="jb"><optionvalue="">选择级别</option><optionvalue="1">1</option><optionvalue="2">2</option><optionvalue="3">3</option></select>
排序<selectng-model="px"><option>排序</option><optionvalue="id">id</option><optionvalue="level">级别</option></select><br/>
<buttonstyle="background-color:#008000;margin:6px;color:#FFFFFF;"ng-click="m=true">新增用户</button><buttonstyle="color:#FFFFFF;background-color:crimson;margin:6px;"ng-click="delso()">批量删除</button>
<divstyle="width:1000px;border:1pxsolidgreenyellow;"ng-show="m">
id:<inputtype="number"ng-model="tid"/>用户名:<inputng-model="tname"/>密码:<inputng-model="tpwd"/>级别:<inputtype="number"ng-model="tlevel"/><buttonng-click="insert(m=false)">添加</button>
</div>
<tablestyle="width:1000px;"border="1px">
<trstyle="background-color:cadetblue;">
<td><inputtype="checkbox"ng-click="ckAll()"ng-model="flag"/></td>
<td>id</td>
<td>用户名</td>
<td>密码</td>
<td>级别</td>
<td>操作</td>
</tr>
<trid="cll"ng-repeat="einuser|orderBy:px:false|filter:{name:souname}|filter:{level:jb}">
<td><inputtype="checkbox"ng-model="e.ck"/></td>
<td>{{e.id}}</td>
<td>{{e.name}}</td>
<td><span>{{e.pwd}}</span>
<spanng-show="f">
<inputng-model="e.pwd"/><buttonng-click="f=false">保存</button>
</span></td>
<td>{{e.level}}</td>
<td><buttonng-click="f=true">修改密码</button></td>
</tr>
</table>
</div>
</body>
</html>


本文转载自中文网
本文转载自中文网
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h55032.shtml