angular排序

来源:互联网 发布:win7时间校准软件 编辑:程序博客网 时间:2024/06/06 14:59
<scripe>
$scope.revers=false;    $scope.sortColumn="name";    $scope.sort=function(column){        if( $scope.sortColumn==column){            $scope.revers=!$scope.revers;        }        $scope.sortColumn=column;    }});
<scripe>
<table>    <thead>    <tr>        <th ng-click="sort('name')">姓名</th>        <th ng-click="sort('age')">年龄</th>        <th ng-click="sort('sex')">性别</th>        <th ng-click="sort('salary')">薪资</th>    </tr>    </thead>    <tbody>    <tr ng-repeat="item in data|filter:{name:search}|orderBy:sortColumn:revers">        <td>{{item.name}}</td>        <td>{{item.age}}</td>        <td>{{item.sex}}</td>        <td>{{item.salary}}</td>    </tr>    </tbody></table>


原创粉丝点击