温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

angularJs中表格如何实现添加删除修改查询方法

发布时间:2021-07-22 14:20:34 来源:亿速云 阅读:147 作者:小新 栏目:web开发

这篇文章给大家分享的是有关angularJs中表格如何实现添加删除修改查询方法的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

如下所示:

<!DOCTYPE html> <html lang="en"> <head>  <meta charset="UTF-8">  <title>Title</title>  <script src="agl/angular.min.js"></script>  <script>   var 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<$scope.arr.length;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;    }   })  </script>  <link rel="stylesheet" href="css/style.css" rel="external nofollow" > </head> <body ng-app="mpp" ng-controller="ctrl"> <div class="inner">  <input type="text" placeholder="用户名查询" ng-model="user">  <input type="text" placeholder="年龄范围查询" ng-model="ages">  <select ng-model="sexs">   <option value="男">男</option>   <option value="女">女</option></select>  <button>全部删除</button>  <TABLE>   <tr>    <th>Id</th>    <th>用户名</th>    <th>密码</th>    <th>年龄</th>    <th>性别</th>    <th>操作</th>   </tr>   <tr ng-repeat="item in arr|filter:{name:user}|filter:{age:ages}|filter:{sex:sexs}">    <td>{{$index+1}}</td>    <td>{{item.name}}</td>    <td>{{item.password}}</td>    <td>{{item.age}}</td>    <td>{{item.sex}}</td>    <td><button ng-click="show()">修改密码</button></td>   </tr>  </TABLE>  <button ng-click="add()">添加用户</button>  <div class="conner">  <div class="add">   用户名:<input type="text" ng-model="name"><br>   密 码:<input type="password" ng-model="password"><br>   年 龄:<input type="text" ng-model="age"><br>   性 别:<select ng-model="sex">   <option value="男">男</option>   <option value="女">女</option></select><br>  </div>  <div class="update" ng-show="flag">   用户名:<input type="text" ng-model="name2"><br>   旧密码:<input type="text" ng-model="pass"><br>   新密码:<input type="password" ng-model="pass2"><br>   确认密码:<input type="password" ng-model="pass3"><br>  </div>  </div>  <button ng-click="submit()">提交</button> </div> </body> </html>

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; }

感谢各位的阅读!关于“angularJs中表格如何实现添加删除修改查询方法”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI