本文主要介绍了Angular搜索 过滤 批量删除 添加 表单验证功能集锦(实例代码),需要的朋友可以参考下,希望能帮助到大家。
废话不多说了,直接给大家贴代码,具体代码如下所示;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> *{ margin: 0; padding: 0; } .sspan{ background: #28a54c; color: #fff; margin-left: 5px; } th,td{ border: 1px solid #000; padding: 10px; } table{ text-align: center; width: auto; border-collapse: collapse; } button{ margin-top: 10px; margin-bottom: 10px; } </style> </head> <body ng-app="myapp" ng-controller="myCtrl"> <p style="width: 1000px"> <input type="text" placeholder="用户名搜索" ng-model="yhmss"/> <input type="text" placeholder="手机号搜索" ng-model="sjhss"/> <select ng-model="Choicecity"> <option>选择城市</option> <option>北京</option> <option>上海</option> <option>天津</option> <option>重庆</option> </select> <select ng-model="Choicestate"> <option>选择状态</option> <option>发货</option> <option>已发货</option> </select> <select ng-model="Choiceorder"> <option>开始月份</option> <option>8</option> <option>9</option> <option>10</option> </select> - <select> <option>结束月份</option> <option>8</option> <option>9</option> <option>10</option> </select> </p> <button ng-click="tianjia()">新增订单</button> <button ng-click="plsc()">批量删除</button> <table> <thead> <tr style="background: #4404"> <th><input type="checkbox" ng-model="checkAll" ng-click="quan()"/></th> <th>id<button ng-click="sort('id')" class="sspan">排序</button></th> <th>商品名</th> <th>用户名</th> <th>手机号</th> <th>价格<button ng-click="sort('price')" class="sspan">排序</button></th> <th>城市</th> <th>下单时间<button ng-click="sort('order')" class="sspan">排序</button></th> <th>状态</th> </tr> </thead> <tbody> <tr ng-repeat="item in data|filter:{name:yhmss}|filter:{phone:sjhss}|filter:cityFun|filter:stateFun|filter:orderFun|orderBy:cc:dd"> <td><input type="checkbox" ng-model="item.done"/></td> <td>{{$index+1}}</td> <td>{{item.commodity}}</td> <td>{{item.name}}</td> <td>{{item.phone}}</td> <td>{{item.price}}</td> <td>{{item.city}}</td> <td>{{item.order}}</td> <td ng-click="fahuo($index)"> {{item.state}} </td> </tr> </tbody> </table> <p ng-show="tj" style="margin-left: 200px" > <h1>添加</h1> <form name="registerForm" novalidate> <p id="email-group"> <label for="email">E-mail:</label> <input type="email" class="form-control" ng-model="email" name="email" id="email" placeholder="请输入电子邮箱..." required> <p> <span style="color: red" ng-show=" registerForm.email.$invalid"> <span ng-show="registerForm.email.$error.required">*请输入邮箱</span> <span ng-show="registerForm.email.$error.email">*请输入正确的email地址</span> </span> </p> </p> <p id="name-group"> <label for="name">昵称:</label> <input type="text" class="form-control" ng-model="name" name="name" id="name" placeholder="请输入昵称..." required> <p> <span style="color: red" ng-show="registerForm.name.$invalid"> <span ng-show="registerForm.name.$error.required">*请输入姓名</span> </span> </p> </p> <p id="password-group"> <label for="password">密码:</label> <input type="password" class="form-control" ng-model="password" ng-minlength="6" ng-maxlength="20" name="password" id="password" placeholder="请输入密码..." required> <p> <span style="color: red" ng-show="registerForm.password.$invalid"> <span ng-show="registerForm.password.$error.minlength">*密码长度不小于6</span> <span ng-show="registerForm.password.$error.maxlength">*密码长度不超过20</span> </span> </p> </p> <p id="passwordagaingroup"> <label for="passwordagain">再输入一遍密码:</label> <input type="password" class="form-control" ng-model="passwordagain" name="passwordagain" id="passwordagain" placeholder="请再输一遍密码..." required> <p> <span style="color: red" ng-show="registerForm.password.$valid"> <span ng-show="passwordagain!=password">*两次密码输入不一致</span> </span> </p> </p> <button type="submit" class="btn btn-success" ng-click="tianjiapp()" ng-disabled="registerForm.email.$invalid || registerForm.name.$invalid || registerForm.password.$invalid || password != passwordagain"> 提交<span class="fa fa-arrow-right"></span> </button> </form> </p> </body> </html> <script src="angular.js"></script> <script> var app = angular.module("myapp",[]); app.controller("myCtrl",function ($scope) { $scope.data = [ { commodity:"iPhone4", name:"张三", phone:151111111, price:4999, city:"北京", order:"8-1", state:"发货", done:false }, { commodity:"小米6", name:"李四", phone:15222222, price:2999, city:"北京", order:"8-2", state:"发货", done:false }, { commodity:"华为P9", name:"王五", phone:153333333, price:3999, city:"上海", order:"9-3", state:"已发货", done:false }, { commodity:"OPPO R11", name:"赵六", phone:15444444, price:4999, city:"天津", order:"9-4", state:"已发货", done:false }, { commodity:"ViVo", name:"钱七", phone:155555555, price:2999, city:"重庆", order:"10-4", state:"已发货", done:false } ]; $scope.Choicecity = "选择城市"; $scope.cityFun = function (item) { if($scope.Choicecity != "选择城市"){ if( item.city == $scope.Choicecity){ return true; }else { return false; } }else { return true; } }; $scope.Choicestate = "选择状态"; $scope.stateFun = function (item) { if($scope.Choicestate != "选择状态"){ if(item.state == $scope.Choicestate){ return true; }else { return false; } }else { return true; } }; $scope.pl = "已发货"; $scope.fahuo = function (index) { if($scope.data[index].state=="发货"){ $scope.data[index].state =$scope.pl; } }; $scope.Choiceorder = "开始月份"; $scope.orderFun = function (item) { if($scope.Choiceorder != "开始月份"){ var arr = $scope.order.split("-"); var min = arr[0]; var max = arr[1]; if(item.order >= min){ return false; }else { return true; } }else { return true; } } $scope.quan = function () { if($scope.checkAll == true){ for(var i = 0 ; i <$scope.data.length ; i++){ $scope.data[i].done = true; } }else{ for(var i = 0 ; i <$scope.data.length ; i++){ $scope.data[i].done = false; } } }; $scope.plsc = function () { for(var i = 0 ; i <$scope.data.length ; i++){ if($scope.data[i].done == true){ $scope.data.splice(i,1); i--; } } }; $scope.tj = false; $scope.tianjia = function () { $scope.tj = true; }; $scope.error = false; $scope.tijiaola = function () { if($scope.commoditys==null||$scope.names==null|| $scope.commoditys<6||$scope.commoditys.length>20){ $scope.error = true; } }; $scope.dd = false; $scope.cc = "id"; $scope.sort = function (couldm) { if($scope.cc == couldm ){ $scope.dd =! $scope.dd; } $scope.cc = couldm; } $scope.tianjiapp = function () { $scope.data.push({commodity:$scope.email,name:$scope.name,phone:$scope.password}) } }) </script>
相关推荐:
以上是Angular搜索 过滤 批量删除一些功能总结的详细内容。更多信息请关注PHP中文网其他相关文章!

JavaScript框架的强大之处在于简化开发、提升用户体验和应用性能。选择框架时应考虑:1.项目规模和复杂度,2.团队经验,3.生态系统和社区支持。

引言我知道你可能会觉得奇怪,JavaScript、C 和浏览器之间到底有什么关系?它们之间看似毫无关联,但实际上,它们在现代网络开发中扮演着非常重要的角色。今天我们就来深入探讨一下这三者之间的紧密联系。通过这篇文章,你将了解到JavaScript如何在浏览器中运行,C 在浏览器引擎中的作用,以及它们如何共同推动网页的渲染和交互。JavaScript与浏览器的关系我们都知道,JavaScript是前端开发的核心语言,它直接在浏览器中运行,让网页变得生动有趣。你是否曾经想过,为什么JavaScr

Node.js擅长于高效I/O,这在很大程度上要归功于流。 流媒体汇总处理数据,避免内存过载 - 大型文件,网络任务和实时应用程序的理想。将流与打字稿的类型安全结合起来创建POWE

Python和JavaScript在性能和效率方面的差异主要体现在:1)Python作为解释型语言,运行速度较慢,但开发效率高,适合快速原型开发;2)JavaScript在浏览器中受限于单线程,但在Node.js中可利用多线程和异步I/O提升性能,两者在实际项目中各有优势。

JavaScript起源于1995年,由布兰登·艾克创造,实现语言为C语言。1.C语言为JavaScript提供了高性能和系统级编程能力。2.JavaScript的内存管理和性能优化依赖于C语言。3.C语言的跨平台特性帮助JavaScript在不同操作系统上高效运行。

JavaScript在浏览器和Node.js环境中运行,依赖JavaScript引擎解析和执行代码。1)解析阶段生成抽象语法树(AST);2)编译阶段将AST转换为字节码或机器码;3)执行阶段执行编译后的代码。

Python和JavaScript的未来趋势包括:1.Python将巩固在科学计算和AI领域的地位,2.JavaScript将推动Web技术发展,3.跨平台开发将成为热门,4.性能优化将是重点。两者都将继续在各自领域扩展应用场景,并在性能上有更多突破。

Python和JavaScript在开发环境上的选择都很重要。1)Python的开发环境包括PyCharm、JupyterNotebook和Anaconda,适合数据科学和快速原型开发。2)JavaScript的开发环境包括Node.js、VSCode和Webpack,适用于前端和后端开发。根据项目需求选择合适的工具可以提高开发效率和项目成功率。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3汉化版
中文版,非常好用

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

Dreamweaver CS6
视觉化网页开发工具

Dreamweaver Mac版
视觉化网页开发工具

SublimeText3 Linux新版
SublimeText3 Linux最新版