angularjs-添加数据,姓名查询,过滤敏感字符,下拉菜单查询
2017-10-23 19:02
609 查看
<!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="UTF-8"> <script type="text/javascript" src="jquery.1.12.4.js"></script> <script type="text/javascript" src="angular-1.3.0.js"></script> <title>angularjs</title> <style type="text/css"> .even_cls { background-color: #fff; } .odd_cls { background-color: #999; } </style> <script type="text/javascript"> //创建数据 var example_data = [ { xing_ming: "张三", wei_zhi: "控球后卫", qiu_hao: 11, piao_shu: 999 }, { xing_ming: "李四", wei_zhi: "大前锋", qiu_hao: 21, piao_shu: 888 }, { xing_ming: "王五", wei_zhi: "小前锋", qiu_hao: 23, piao_shu: 777 }, { xing_ming: "赵六", wei_zhi: "中锋", qiu_hao: 10, piao_shu: 666 }, { xing_ming: "周七", wei_zhi: "得分后卫", qiu_hao: 1, piao_shu: 555 } ]; var app = angular.module("myApp", []); app.service("a", function () { this.findAll = function () { }; this.getRow = function () { }; }); app.factory("a", function () { return { findAll: function() {}, getRow: function() {} }; }); app.factory("$interval", function () { return function() {}; }); app.constant("EXAMPLE_DATA", example_data); app.controller("myCtrl", function ($scope, EXAMPLE_DATA) { //进行排序 $scope.data = EXAMPLE_DATA; $scope.add_qiu_yuan_form = false; $scope.showAddQiuYuanForm = function () { $scope.add_qiu_yuan_form = true; }; //对数据进行判断 $scope.submitQiuYuanForm = function () { if ($scope.xing_ming == undefined || $scope.xing_ming == "") { // alert("姓名不能为空!"); return; } if ($scope.wei_zhi == undefined || $scope.wei_zhi == "") { return; } if ($scope.qiu_hao == undefined || $scope.qiu_hao == "") { return; } if ($scope.piao_shu == undefined || $scope.piao_shu == "") { return; } if (!/^\d+$/.test($scope.qiu_hao)) { alert("球号必须是整数!"); return; } if (!/^\d+$/.test($scope.piao_shu)) { alert("票数必须是整数!"); return; } //添加数据 $scope.data.push( { xing_ming: $scope.xing_ming, wei_zhi: $scope.wei_zhi, qiu_hao: $scope.qiu_hao, piao_shu: $scope.piao_shu } ); $scope.xing_ming = ""; $scope.wei_zhi = ""; $scope.qiu_hao = ""; $scope.piao_shu = ""; $scope.add_qiu_yuan_form = false; }; //判断敏感词,是敏感词显示为**** $scope.search = function () { if ($scope.search_xing_ming_value == undefined || $scope.search_xing_ming_value == "") { $("tr").show(); return; } if ($scope.search_xing_ming_value == "习近平") { alert("敏感词"); return; } for (var idx in $scope.data) { var trIdx = parseInt(idx) + 1; if ($scope.search_xing_ming_value == $scope.data[idx].xing_ming) { $("tr:eq(" + trIdx + ")").show(); } else { $("tr:eq(" + trIdx + ")").hide(); } } }; $scope.order2 = function (num) { if (num == "") { return; } return (parseInt(num) == 2) ? true : false; } }); app.filter("mgc", function () { return function (msg, flag) { return msg.replace(flag, "***"); }; }); </script> </head> <body ng-controller="myCtrl"> 查询:<input type="text" ng-model="search_xing_ming_value" ng-change="search()"/> <select ng-model="search_piao_shu_value"> <option value="">排序</option> <option value="1">票数正序</option> <option value="2">票数倒序</option> </select><br/> <button ng-click="showAddQiuYuanForm()">新增球员</button> <table border="1"> d204 <thead> <tr style="background-color: #666"> <th>姓名</th> <th>位置</th> <th>球号</th> <th>票数</th> </tr> </thead> <tbody> <tr ng-repeat="qiu_yuan in data | orderBy: 'piao_shu': order2(search_piao_shu_value)" ng-class="{even_cls: !$even, odd_cls: !$odd}"> <td>{{ qiu_yuan.xing_ming | mgc: '习近平' }}</td> <td ng-bind="qiu_yuan.wei_zhi"></td> <td ng-bind="qiu_yuan.qiu_hao"></td> <td ng-bind="qiu_yuan.piao_shu"></td> </tr> </tbody> </table> <div>敏感词:习近平</div> <div ng-show="add_qiu_yuan_form"> <p>添加球员</p> <p>姓名:<input type="text" ng-model="xing_ming"/></p> <p>位置:<input type="text" ng-model="wei_zhi"/></p> <p>球号:<input type="text" ng-model="qiu_hao"/></p> <p>票数:<input type="text" ng-model="piao_shu"/></p> <p> <button ng-click="submitQiuYuanForm()">提交</button> </p> </div> </body> </html>
相关文章推荐
- AngularJS实现下拉框排序/添加数据/查询数据/敏感字符过滤
- (angularjs) 数据的增查(添加用户,查询名字,实现排序,判断非空 ,是否是数字,是否重名,敏感字符)
- 隔行变色,选中变色,鼠标变小手样式;姓名查询条件 过滤敏感字符 下拉列表排序 非空验证添加信息 点击按钮删除
- 3:AngularJS:模糊查询过滤内容,下拉菜单排序,过滤敏感字符,验证判断后添加表格信息
- AngularJS_table添加/批量删除数据/过滤敏感字符
- AngularJS模糊查询功能实现代码(过滤内容下拉菜单排序过滤敏感字符验证判断后添加表格信息)
- 用户信息:奇偶数隔行变色,选中行变色,鼠标变小手样式;姓名查询条件,过滤敏感字符;下拉列表排序;非空验证添加信息;点击按钮删除
- angularJS实现查询/选择排序/添加/敏感字符过滤
- AngularJS敏感词过滤,下拉菜单排序,表格隔行换色,添加数据
- 1. AngularJS+路由+JQuery:模糊查询过滤内容,下拉菜单排序,过滤敏感字符,验证判断后添加表格信息(路由显示添加页面)
- 2. AngularJs+JQuery:模糊查询过滤内容,下拉菜单排序,过滤敏感字符,验证判断后添加表格信息
- AngularJS 添加 查询 排序 删除 数据 敏感词
- AngularJs+JQuery:模糊查询过滤内容,下拉菜单排序,过滤敏感字符,验证判断后添加表格信息
- 表格(查询数据 、 排序 、添加数据 、敏感词)
- php过滤所有恶意字符(批量过滤post,get敏感数据)
- AngularJS综合用户信息, 表单验证,过滤查询,全选反选,批量删除,修改,添加
- angularjs-查询.删除,添加数据,修改密码
- php过滤所有恶意字符(批量过滤post,get敏感数据)经典
- Bootstrap + AngularJS 实现简单的数据过滤----字符查找
- angular 请求网络数据 展示table 查询关键字 过滤 删除 添加 修改