本文主要和大家分享angularJs实现表格添加删除修改查询功能代码,希望能帮助到大家。
如下所示:
Titlevar app=angular.module("mpp",[]);
app.controller("ctrl",function ($scope) {
$scope.arr=[];
$scope.add=function () {
$scope.arr.push({name:$scope.name,password:$scope.password,age:$scope.age,sex:$scope.sex})
}
$scope.submit=function () {
for (var i=0;i
{
if($scope.arr[i].name==$scope.name2)
{
if($scope.arr[i].password==$scope.pass)
{
if($scope.pass2==$scope.pass){
$scope.arr[i].password=$scope.pass2;
}else{
alert("两次输入不一致");
}
}else {
alert("密码错误");
}
}else {
alert("用户名错误");
}
}
}
$scope.flag=false;
$scope.show=function () {
$scope.flag=true;
}
})
男
女
全部删除
Id | 用户名 | 密码 | 年龄 | 性别 | 操作 |
---|---|---|---|---|---|
{{$index+1}} | {{item.name}} | {{item.password}} | {{item.age}} | {{item.sex}} | 修改密码 |
添加用户
用户名:
密 码:
年 龄:
性 别:
男
女
用户名:
旧密码:
新密码:
确认密码:
提交
css
*{
margin: 0;
padding: 0;
}
.inner{
margin: 20px auto;
text-align: center;
}
table{
margin: 10px auto;
text-align: center;
}
tr{
border-collapse: collapse;
}
tr th,td{
border:1px solid #000000;
width: 60px;
}
.conner{
width: 600px;
height: 300px;
background: #ffe7e0;
margin: 0 auto;
}
.add{
margin: 10px auto;
padding-top: 20px;
width: 260px;
height: 120px;
border: 2px solid #e42112;
}
.update{
width: 280px;
height: 120px;
border: 2px solid #e42112;
text-align: center;
margin: 10px auto;
padding-top: 20px;
}
相关推荐: