2016-01-09 81 views
1

我想基於多個選擇菜單進行orderBy。例如:Angularjs orderBy基於多個選擇菜單

Order : 
<select ng-model="filterOrder"> 
    <option value="+">- to +</option> 
    <option value="-">+ to -</option> 
</select> 

Column: 
<select ng-model="filterColumn"> 
    <option value="name">Name</option> 
    <option value="age">Age</option> 
</select> 

<div ng-repeat="user in users|orderBy:'filterOrder.filterColumn'"> 
     {{user.name}} {{user.age}} <br> 
</div>   

謝謝!

回答

1

你想用的orderBy

<div ng-repeat="user in users|orderBy:filterColumn: filterOrder == '-'"> 

表達filterOrder == '-'reverse參數將返回一個布爾對於這樣的說法