orderBy and filter inside the same ng-repeat

162 views Asked by At

I have a table on which is implement sorting on columns and filter after a column (type).

It works fine if I use either orderBy or filter but does not work ( there is no data showed in the table) if there are both in ng-repeat.

This is the code:

 <tr ng-repeat="rows in $ctrl.myData |
     orderBy:$ctrl.sort.active:$ctrl.sort.descending track by $index |
     filter: {Type:type} track by $index"
 >

If I use like this it works the filter:

<tr ng-repeat="rows in $ctrl.myData | filter: {Type:type} track by $index">

and like this it works the ordering:

<tr ng-repeat="rows in $ctrl.myData | orderBy:$ctrl.sort.active:$ctrl.sort.descending track by $index">

Why isn't it work for both?

1

There are 1 answers

0
dadsa On

Probably the problem is caused by the presence of two track by $index.

Changing it to

<tr ng-repeat="rows in $ctrl.myData|   
    orderBy:$ctrl.sort.active:$ctrl.sort.descending |        
    filter: {Type:type} track by $index"
> 

solved the problem.