angular.js实现列表orderby排序的方法
2019/6/26 23:25:44
本文主要是介绍angular.js实现列表orderby排序的方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
如下所示:
<html ng-app> <head> <title>order by</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width,initial-scale=1" /> <link href="../book/css/bootstrap.css" rel="external nofollow" rel="stylesheet" type="text/css" /> <script src="../file/angular-1.0.1.min.js" type="text/javascript"></script> </head> <body> <div class="table-responsive" ng-controller="demoController"> <table id="tb" class="table table-bordered table-hover"> <thead> <tr> <th class="col-md-2">编号</th> <th class="col-md-4">国家</th> <th class="col-md-4">名称</th> <th class="col-md-3">年龄</th> </tr> </thead> <tbody id="tbody" ng-repeat="stu in data | orderBy : '-age' | limitTo: 10"> <tr class="{{ cls($index) }}"> <td>{{ $index + 1 }}</td><td>{{ stu.country }}</td><td>{{ stu.name }}</td><td>{{ stu.age }}</td> </tr> </tbody> </table> </div> <script type="text/javascript"> function demoController($scope,$window) { $scope.data = [ { seq: 1, name: "魏国", country: "曹操",age : 45 }, { seq: 2, name: "魏国", country: "张辽" ,age: 34}, { seq: 3, name: "魏国", country: "司马懿" ,age: 36 }, { seq: 4, name: "魏国", country: "夏侯淳",age: 40 }, { seq: 5, name: "蜀国", country: "刘备",age: 50 }, { seq: 6, name: "蜀国", country: "关羽",age: 45 }, { seq: 7, name: "蜀国", country: "张飞",age: 46 }, { seq: 8, name: "蜀国", country: "赵云",age: 35 }, { seq: 9, name: "吴国", country: "孙权" ,age: 30 }, { seq: 10, name: "吴国", country: "周瑜",age: 32 }, { seq: 11, name: "吴国", country: "鲁肃",age: 33 }, { seq: 12, name: "吴国", country: "黄盖",age: 55 } ]; $scope.cls = function(i) { return (i + 1) % 4 == 1 ? "active" : ""; } } </script> </body> </html>
效果:
以上这篇angular.js实现列表orderby排序的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持找一找教程网。
这篇关于angular.js实现列表orderby排序的方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-24Vue CLI多环境配置学习:从入门到实践
- 2024-11-24Vue CLI多环境配置学习:新手入门教程
- 2024-11-24Vue CLI学习:初学者指南
- 2024-11-24Vue CLI学习:从入门到上手的简单教程
- 2024-11-24Vue3+Vite学习:从零开始的前端开发之旅
- 2024-11-24Vue3阿里系UI组件学习入门教程
- 2024-11-24Vue3的阿里系UI组件学习入门指南
- 2024-11-24Vue3公共组件学习:新手入门教程
- 2024-11-24Vue3公共组件学习入门指南
- 2024-11-24vue3核心功能响应式变量学习