<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="../zhoukao2/js/angular.min.js" ></script>
<script type="text/javascript" src="../js/jquery-1.11.1.js" ></script>
<script>
angular.module("weihaorong",[]).controller("demo1",function($scope){
$scope.datas=[{id:'1',name:'曹操',password:'123456',jibie:'2',address:'北京-海淀',time:'2017-10-01 10:00:00'},{id:'2',name:'刘备',password:'123456',jibie:'1',address:'河北-石家庄',time:'2017-10-01 10:00:00'},{id:'3',name:'司马懿',password:'123456',jibie:'1',address:'河北-承德',time:'2017-10-01 10:00:00'}];
$scope.save=function(){
$scope.errors=null;
//添加的对象值
if($scope.id==undefined||$scope.id==""){
if($scope.errors==null){
$scope.errors={};
}
//
$scope.errors.id="id不能为空";
}
if($scope.errors==null){
$scope.datas.push({
id:$scope.id,
name:$scope.name,
password:$scope.password,
jibie:$scope.jibie,
address:$scope.address,
time:$scope.time
});
$scope.isshow=false;
}
}
$scope.del=function(){
for(var i=0;i<$scope.datas.length;i++){
if($scope.datas[i].c){
$scope.datas.splice(i,1);
i--;
}
}
}
$scope.qx=function(){
for(var i=0;i<$scope.datas.length;i++){
$scope.datas[i].c=$scope.ck;
}
}
})
</script>
</head>
<body ng-app="weihaorong" ng-controller="demo1">
<input ng-model="gname" placeholder="用户名搜索"/>
<select ng-model="jibie1">
<option value="">选择级别</option>
<option>1</option>
<option>2</option>
</select>
<select ng-model="pp">
<option value="">排序</option>
<option value="+id">id正序</option>
<option value="-id">id倒序</option>
<option value="+jibie">级别正序</option>
<option value="-jibie">级别倒序</option>
<option value="+time">时间正序</option>
<option value="-time">时间倒序</option>
</select><br />
<button ng-click="isshow=true">新增用户</button>
<button ng-click="del()">批量删除</button>
<table border="1px">
<tr>
<td><input type="checkbox" ng-model="ck" ng-click="qx()"></td>
<td>id</td>
<td>用户名</td>
<td>密码</td>
<td>级别</td>
<td>地址</td>
<td>时间</td>
<td>操作</td>
</tr>
<tr ng-repeat="d in datas|filter:{name:gname,jibie:jibie1}|orderBy:pp">
<td><input type="checkbox" ng-model="d.c"/></td>
<td>{{d.id}}</td>
<td>{{d.name}}</td>
<td><span ng-hide="update">{{d.password}}</span><input ng-model="d.password" ng-show="update" ng-blur="update=false"></td>
<td>{{d.jibie}}</td>
<td>{{d.address}}</td>
<td>{{d.time}}</td>
<td><button ng-click="update=true">修改</button></td>
</tr>
</table>
<form ng-show="isshow">
id:<input ng-model="id" ng-class="{myborder:id==null||id==''}"/>{{errors.id}}<br />
name:<input ng-model="name" ng-class="{myborder:name==null||name==''}"/>{{errors.name}}<br />
password:<input ng-model="password" ng-class="{myborder:password==null||password==''}"/>{{errors.password}}<br />
jibie:<input ng-model="jibie" ng-class="{myborder:jibie==null||jibie==''}"/>{{errors.jibie}}<br />
省:<select id="p" ng-model="pro" οnchange="getcity()">
<option>北京</option>
<option>河北</option>
<option>山西</option>
</select>
市:<select id="city" ng-model="city">
<option value="">请选择城市</option>
</select>
time:<input ng-model="time" ng-class="{myborder:time==null||time==''}"/>{{errors.time}}<br />
<button ng-click="save()">保存</button>
</form>
</body>
<script>
var citys=[{pro:"北京",cs:["海淀","昌平","朝阳"]},
{pro:"河北",cs:["廊坊","石家庄","保定"]},
{pro:"山西",cs:["长治","太原","临汾"]}
];
function getcity(){
var p = $("#p").val();
var cts=[];
for (var i=0;i<citys.length;i++) {
if(p==citys[i].pro){
cts=citys[i].cs;
}
}
$("#city option").remove();
for(var i=0;i<cts.length;i++){
var op=$("<option>"+cts[i]+"</option>");
$("#city").append(op);
}
}
</script>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="../zhoukao2/js/angular.min.js" ></script>
<script type="text/javascript" src="../js/jquery-1.11.1.js" ></script>
<script>
angular.module("weihaorong",[]).controller("demo1",function($scope){
$scope.datas=[{id:'1',name:'曹操',password:'123456',jibie:'2',address:'北京-海淀',time:'2017-10-01 10:00:00'},{id:'2',name:'刘备',password:'123456',jibie:'1',address:'河北-石家庄',time:'2017-10-01 10:00:00'},{id:'3',name:'司马懿',password:'123456',jibie:'1',address:'河北-承德',time:'2017-10-01 10:00:00'}];
$scope.save=function(){
$scope.errors=null;
//添加的对象值
if($scope.id==undefined||$scope.id==""){
if($scope.errors==null){
$scope.errors={};
}
//
$scope.errors.id="id不能为空";
}
if($scope.errors==null){
$scope.datas.push({
id:$scope.id,
name:$scope.name,
password:$scope.password,
jibie:$scope.jibie,
address:$scope.address,
time:$scope.time
});
$scope.isshow=false;
}
}
$scope.del=function(){
for(var i=0;i<$scope.datas.length;i++){
if($scope.datas[i].c){
$scope.datas.splice(i,1);
i--;
}
}
}
$scope.qx=function(){
for(var i=0;i<$scope.datas.length;i++){
$scope.datas[i].c=$scope.ck;
}
}
})
</script>
</head>
<body ng-app="weihaorong" ng-controller="demo1">
<input ng-model="gname" placeholder="用户名搜索"/>
<select ng-model="jibie1">
<option value="">选择级别</option>
<option>1</option>
<option>2</option>
</select>
<select ng-model="pp">
<option value="">排序</option>
<option value="+id">id正序</option>
<option value="-id">id倒序</option>
<option value="+jibie">级别正序</option>
<option value="-jibie">级别倒序</option>
<option value="+time">时间正序</option>
<option value="-time">时间倒序</option>
</select><br />
<button ng-click="isshow=true">新增用户</button>
<button ng-click="del()">批量删除</button>
<table border="1px">
<tr>
<td><input type="checkbox" ng-model="ck" ng-click="qx()"></td>
<td>id</td>
<td>用户名</td>
<td>密码</td>
<td>级别</td>
<td>地址</td>
<td>时间</td>
<td>操作</td>
</tr>
<tr ng-repeat="d in datas|filter:{name:gname,jibie:jibie1}|orderBy:pp">
<td><input type="checkbox" ng-model="d.c"/></td>
<td>{{d.id}}</td>
<td>{{d.name}}</td>
<td><span ng-hide="update">{{d.password}}</span><input ng-model="d.password" ng-show="update" ng-blur="update=false"></td>
<td>{{d.jibie}}</td>
<td>{{d.address}}</td>
<td>{{d.time}}</td>
<td><button ng-click="update=true">修改</button></td>
</tr>
</table>
<form ng-show="isshow">
id:<input ng-model="id" ng-class="{myborder:id==null||id==''}"/>{{errors.id}}<br />
name:<input ng-model="name" ng-class="{myborder:name==null||name==''}"/>{{errors.name}}<br />
password:<input ng-model="password" ng-class="{myborder:password==null||password==''}"/>{{errors.password}}<br />
jibie:<input ng-model="jibie" ng-class="{myborder:jibie==null||jibie==''}"/>{{errors.jibie}}<br />
省:<select id="p" ng-model="pro" οnchange="getcity()">
<option>北京</option>
<option>河北</option>
<option>山西</option>
</select>
市:<select id="city" ng-model="city">
<option value="">请选择城市</option>
</select>
time:<input ng-model="time" ng-class="{myborder:time==null||time==''}"/>{{errors.time}}<br />
<button ng-click="save()">保存</button>
</form>
</body>
<script>
var citys=[{pro:"北京",cs:["海淀","昌平","朝阳"]},
{pro:"河北",cs:["廊坊","石家庄","保定"]},
{pro:"山西",cs:["长治","太原","临汾"]}
];
function getcity(){
var p = $("#p").val();
var cts=[];
for (var i=0;i<citys.length;i++) {
if(p==citys[i].pro){
cts=citys[i].cs;
}
}
$("#city option").remove();
for(var i=0;i<cts.length;i++){
var op=$("<option>"+cts[i]+"</option>");
$("#city").append(op);
}
}
</script>
</html>