First define a json file:
##Then write the HTML file:
1 <div id="box"> 2 <!--第一个下拉框--> 3 <select ng-model="a"> 4 <option value="age">按照年龄排序</option> 5 <option value="code">按照编码排序</option> 6 <option value="name">按照姓名排序</option> 7 </select> 8 <!--升序还是降序--> 9 <select ng-model="b">10 <option value="">升序</option>11 <option value="-">降序</option>12 </select>13 <!--一个搜索框-->14 <input type="text" placeholder="请输入要搜索的内容" ng-model="c"/>15 </div>16 <!--渲染的数据-->17 <div id="wrap">18 <table>19 <tr>20 <th>编码</th>21 <th>姓名</th>22 <th>年龄</th>23 </tr>24 <tr ng-repeat="item in data|filter:c|orderBy:b+a">25 <td>{{item.code}}</td>26 <td>{{item.name}}</td>27 <td>{{item.age}}</td>28 </tr>29 </table>30 </div>31
angular:
1 <script>2 var app = angular.module("mk",[]);3 app.controller("test",function($scope,$http){4 $http.get('json/index.json').success(function(data){5 $scope.data = eval(data);6 $scope.a = "code";7 })8 })9 </script>
The filters used in this type include
filter and orderBy
This completes a simple sorting, I hope it can help everyone! ! ! ! ! ! ! !
The above is the detailed content of How to sort angular filters?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn