我有一个由3列组成的表,如下所示,
A栏|| B栏|| C栏
20 ||拉杰||驱动器
50 ||约翰||驱动器
30 || Bharath ||司机
40 ||杰克||司机
我已经对orderBy属性进行了排序。 如果我按列A排序,则列B和列C将根据A(正确)排序。 但是如果我按C列排序,则A列和B列都按照C排序......但它不应该排序,因为C列具有相同的值。 有没有任何过滤器属性来实现这一目标?如果列中存在相同的值,那么所有列都不应该排序?可能吗?
代码:
<div ng-controller="ExampleController">
<pre>Sort by = {{propertyName}}; reverse = {{reverse}}</pre>
<hr/>
<button ng-click="propertyName = null; reverse = false">Set to unsorted</button>
<hr/>
<table class="friends">
<tr>
<th>
<button ng-click="sortBy('num')">Column A</button>
<span class="sortorder" ng-show="propertyName === 'num'" ng-class="{reverse: reverse}"></span>
</th>
<th>
<button ng-click="sortBy('name')">Column B</button>
<span class="sortorder" ng-show="propertyName === 'name'" ng-class="{reverse: reverse}"></span>
</th>
<th>
<button ng-click="sortBy('occupation')">Column C</button>
<span class="sortorder" ng-show="propertyName === 'occupation'" ng-class="{reverse: reverse}"></span>
</th>
</tr>
<tr ng-repeat="friend in friends | orderBy:propertyName:reverse">
<td>{{friend.num}}</td>
<td>{{friend.name}}</td>
<td>{{friend.occupation}}</td>
</tr>
</table>
</div>