The code snippet provided below is intended for sorting table columns but it seems to be causing an error message:
Error: $injector:unpr Unknown Provider
Unknown provider: orderbyFilterProvider <-
View:
<table class="table table-bordered table-hover">
<thead>
<tr>
<th><a href="" ng-click="reverse=!reverse;order('lname', reverse)">Lastname</a></th>
<th><a href="" ng-click="reverse=!reverse;order('fname', reverse)">Firstname</a></th>
<th><a href="" ng-click="reverse=!reverse;order('maxAge', reverse)">Age</a></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in filteredItems = (nameslist | orderBy:predicate)">
<td>{{ item.lname }}</td>
<td>{{ item.fname }}</td>
<td>{{ item.maxAge }}</td>
</tr>
</tbody>
</table>
Ctrl:
//Retrieve data from REST API
$scope.nameslist = resService.getAll();
//sorting function
var orderby = $filter('orderby');
$scope.order = function (predicate, reverse) {
$scope.nameslist = orderby($scope.nameslist, predicate, reverse);
};
/* default */
$scope.order('-maxAge', false);
resService:
...
return {
getAll: function () {
return requestService.name.query();
},
...
}
Is there a way to modify the sorting function to resolve this issue?