欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

angular過濾器實(shí)現(xiàn)排序功能

 更新時間:2017年06月27日 08:39:08   作者:Code_User  
這篇文章主要為大家詳細(xì)介紹了angular過濾器實(shí)現(xiàn)排序功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了angular過濾器排序的具體代碼,供大家參考,具體內(nèi)容如下

首先定義一個json文件:

 

然后寫HTML文件:

<div id="box">
      <!--第一個下拉框-->
      <select ng-model="a">
        <option value="age">按照年齡排序</option>
        <option value="code">按照編碼排序</option>
        <option value="name">按照姓名排序</option>
      </select>
      <!--升序還是降序-->
      <select ng-model="b">
        <option value="">升序</option>
        <option value="-">降序</option>
      </select>
      <!--一個搜索框-->
      <input type="text" placeholder="請輸入要搜索的內(nèi)容" ng-model="c"/>
    </div>
    <!--渲染的數(shù)據(jù)-->
    <div id="wrap">
      <table>
        <tr>
          <th>編碼</th>
          <th>姓名</th>
          <th>年齡</th>
        </tr>
        <tr ng-repeat="item in data|filter:c|orderBy:b+a">
          <td>{{item.code}}</td>
          <td>{{item.name}}</td>
          <td>{{item.age}}</td>
        </tr>
      </table>
    </div>

angular:

<script>
      var app = angular.module("mk",[]);
      app.controller("test",function($scope,$http){
        $http.get('json/index.json').success(function(data){
            $scope.data = eval(data);
            $scope.a = "code";
        })
      })
    </script>

在這種運(yùn)用到的過濾器有filter 、orderBy

這樣就完成了一個簡單的排序,希望能幫到大家!

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論