Sort filter 'orderBy' not working in AngularJS
I have a list of tables with three columns. It is possible to sort all columns down. When you click on the -Tag, the list is sorted, but I get an error:
Error: $ injector: unpr Unknown supplier
Unknown provider: orderbyFilterProvider <-
Here is Ctrl:
var orderby = $filter('orderby');
$scope.sortType = '-maxAge';
$scope.sortReverse = false;
$scope.order = function (sortType, sortReverse) {
$scope.nameslist = orderby($scope.nameslist, sortType, sortReverse);
};
View (title):
...
<th>
<a href="" ng-click="sortReverse = !sortReverse; order('fname',reverse)">
Firstame
<span ng-show="sortType=='fname' && !sortReverse" class="glyphicon glyphicon-triangle-bottom"></span>
<span ng-show="sortType=='fname' && sortReverse" class="glyphicon glyphicon-triangle-top"></span>
</a>
</th>
...
View (list of tables):
<tr ng-repeat="item in filteredNames = (nameslist | orderBy: sortType:sortReverse)" class="show-cursor">
<td>{{ item.fname }}</td>
...
</tr>
I don't know where is the problem ?!
+3
source to share