模糊查询全部删除添加用户

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../test29/angular.min.js"></script>
    <script>
        var myapp=angular.module("myapp",[]);
        myapp.controller("myCtrl",function ($scope) {
            $scope.data=[{
                name:'a',pass:'111',age:20,sex:'男'
            },{
                name:'b',pass:'2341',age:40,sex:'女'
            },{
                name:'c',pass:'2341',age:22,sex:'女'
            },{
                name:'d',pass:'2541',age:10,sex:'男'
            },{
                name:'e',pass:'2322',age:40,sex:'女'
            }]
            //全部删除的功能
            $scope.deleteall=function () {
                var a=confirm("确定要全部删除吗")
                if(a){
                    $scope.data.splice(0,$scope.data.length);
                }

            }
            //添加用户
            $scope.rece=false;
            $scope.shows=function () {
                $scope.rece=!$scope.rece;

            }
            $scope.submits=function () {
                $scope.data.push({name:$scope.newname,pass:$scope.newpass,age:$scope.newage,sex:$scope.newsex});
                $scope.newname='';
                $scope.newpass='';
                $scope.newage='';
                $scope.newsex='';
                $scope.rece=false;

            }
            $scope.recel=false;
            $scope.inde;
            $scope.show1=function (index) {
                $scope.recel=!$scope.recel;
                $scope.inde=index;

            }
     //修改密码
            $scope.submits1=function () {
                if($scope.oldpass==$scope.data[$scope.inde].pass){

                    if ($scope.newpass1==$scope.newpass2){
                        $scope.data[$scope.inde].pass=$scope.newpass1;

                    }else {
                        alert('两次密码不一致');
                    }
                }else {
                    alert('密码错误');
                }
                $scope.newname1='';
                $scope.oldpass='';
                $scope.newpass1='';
                $scope.newpass2='';

                $scope.recel=false;

            }

        })
    </script>
</head>
<body ng-app="myapp" ng-controller="myCtrl">
<input type="text" placeholder="用户名查询" ng-model="sort">
<input type="text" placeholder="年龄范围查询" ng-model="sort1">
<select>
    <option></option>
    <option></option>
</select>

<button ng-click="deleteall()">全部删除</button>
<table>
    <thead>
    <th>id</th>
    <th>用户名</th>
    <th>密码</th>
    <th>性别</th>
    <th>操作</th>
    </thead>
    <tbody>
    <tr ng-repeat="item in data|filter:sort|filter:sort1">
        <td>{{$index}}</td>
        <td>{{item.name}}</td>
        <td>{{item.pass}}</td>
        <td>{{item.age}}</td>
        <td>{{item.sex}}</td>
        <td><button ng-click="shows1($index)">修改密码</button></td>
    </tr>
    </tbody>
</table>
<button ng-click="shows()">添加用户</button>
<div ng-show="rece">
    用户名:<input type="text" ng-model="newname"><br>
    密码:<input type="text" ng-model="newpass"><br>
    年龄:<input type="text" ng-model="newage"><br>
    性别:<input type="text" ng-model="newsex"><br>
    <button ng-click="submits()">提交</button>

</div>
<div ng-show="recel">
    用户名:<input type="text" ng-model="newname1"><br>
   旧密码:<input type="text" ng-model="oldpass"><br>
    新密码:<input type="text" ng-model="newpass1"><br>
    确认密码:<input type="text" ng-model="newpass2"><br>
    <button ng-click="submits1()">提交</button>


</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值