Reputation: 5217
I have a table of data that I can filter and show only the "Color" rows if I select the "Color Only" item from the sort list. I am doing this by using the following code:
<label>Sort By:</label>
<select ng-model="orderProp" class="form-control" tabindex="2">
<option value="title">Title</option>
<option value="filename">File Name</option>
<option value="class">Classification</option>
<option value="color">Color Only</option>
</select>
And then using ng-repeat on the table element:
<tr ng-repeat="item in filtered = (pptData | filter: query | orderBy: orderProp)" ng-if="orderProp !== 'color' || item.color">
However, how can I display those color results by title? I tried to do the following, but it didn't work:
<option value="{{ 'color' | orderBy:'title' }}">Color Only</option>
Anyone have any ideas? My live demo is here.
Upvotes: 1
Views: 148
Reputation: 3283
I would do something like this,
<tr ng-repeat="item in filtered = (pptData | filter: query | orderBy: [orderProp,'title'])" ng-if="orderProp !== 'color' || item.color">
Basically you first sort by orderProp, then by title.
Upvotes: 0
Reputation: 3025
try something like
$scope.reverse = true; // false
<option value="{{ 'color' | orderBy:title:reverse }}">Color Only</option>
reference: https://docs.angularjs.org/api/ng/filter/orderBy
Upvotes: 1