angular表格的查询添加和排序
来源:互联网 发布:什么网络手机游戏好玩 编辑:程序博客网 时间:2024/05/16 13:40
<!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>第三周周考题</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.order = function () {// if ($scope.search_piao_shu_value == 1) {// $scope.data.sort(function (json1, json2) {// return (json1.piao_shu > json2.piao_shu) ? 1 : -1;// });// } else if ($scope.search_piao_shu_value == 2) {// $scope.data.sort(function (json1, json2) {// return (json1.piao_shu < json2.piao_shu) ? 1 : -1;// });// }// }; $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, "***"); }; }); MVC M : Model V: View C: Ctrl Ctrl </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" ng-change="order()">--><!--<option value="0">排序</option>--><!--<option value="1">票数正序</option>--><!--<option value="2">票数倒序</option>--><!--</select><br/>--><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"> <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>
阅读全文
0 0
- angular表格的查询添加和排序
- angular的查询添加排序
- Angular模糊查询和排序已经添加
- angular表格排序(查询)
- angular js 添加 排序 查询
- angular实现排序,添加,查询
- Angular,添加,删除,查询,排序
- angular表格单个字段查询,修改,添加
- angular的路由表格添加
- angular的添加查找表格
- css+jQuery+angular+table查询排序添加和批量删除
- angular jQuery css html混合table表格查询 排序 添加 删除 隔行换色
- angular 的表格输入添加和批量删除
- angular的表格排序、分页和一些基本操作
- angular(查询、删除、添加、排序)案例
- angular实现添加,删除,查询,排序
- angular js查询 排序 添加 删除
- angular的订单查询添加
- poj1251 Jungle Roads
- linux 运维笔记
- 用DOS命令扫描本网段,得到对应的ARP表
- Openshift Origin开发日记 1
- 启动targetcli时遭遇ImportError: cannot import name ALUATargetPortGroup故障
- angular表格的查询添加和排序
- poj1258 Agri-Net
- 杨辉三角
- 在首席架构师眼里,架构的本质
- Can not set the value of read-only property 'jniFolders' for task ': android: packageDebug
- 关于OpenGL中深度截取(GL_DEPTH_CLAMP)的讲解
- deeplearning-Regularization
- Java基础------构造器
- poj1679 The Unique MST