angularJs利用$scope处理升降序的方法
网络编程 2021-07-04 16:46www.168986.cn编程入门
今天长沙网络推广就为大家分享一篇angularJs利用$scope处理升降序的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随长沙网络推广过来看看吧
如下所示:
<div ng-app="module" ng-controller="ctrl"> <table border="1" width="600"> <tr> <td ng-click="orderBy('id')">编号 <span ng-if="status.id">升序</span> <span ng-if="!status.id">降序</span> </td> <td ng-click="orderBy('click')">点击数 <span ng-if="status.click">升序</span> <span ng-if="!status.click">降序</span> </td> <td ng-click="orderBy('title')">标题 <span ng-if="status.title">升序</span> <span ng-if="!status.title">降序</span> </td> </tr> <tr ng-repeat="(k,v) in data"> <td>{{v.id}}</td> <td>{{v.click}}</td> <td>{{v.title}}</td> </tr> </table> </div> <script> var m = angular.module('module', []); m.controller('ctrl', ['$scope', '$filter', function ($scope, $filter) { $scope.data = [ {id: 1, click: 100, title: '百度'}, {id: 2, click: 200, title: '谷歌'}, {id: 3, click: 300, title: '腾讯'}, ]; //记录排序的状态 $scope.status = {id: false, click: false, title: false}; $scope.orderBy = function (field) { /*切换升序和降序*/ $scope.status[field]=!$scope.status[field]; $scope.data = $filter('orderBy')($scope.data, field, $scope.status[field]); } }]); </script>
效果图:
以上这篇angularJs利用$scope处理升降序的方法就是长沙网络推广分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持狼蚁SEO。
上一篇:vue实现一个炫酷的日历组件
下一篇:Nuxt升级2.0.0时出现的问题(小结)
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程