我有一个包含三列的表格列表。可以对所有列进行排序。当您单击-Tag时,列表将排序,但我收到错误消息:
错误:$ injector:unpr 未知提供商
未知提供者:orderbyFilterProvider< -
这是Ctrl:
var orderby = $filter('orderby');
$scope.sortType = '-maxAge';
$scope.sortReverse = false;
$scope.order = function (sortType, sortReverse) {
$scope.nameslist = orderby($scope.nameslist, sortType, sortReverse);
};
视图(标题):
...
<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>
...
视图(表格列表):
<tr ng-repeat="item in filteredNames = (nameslist | orderBy: sortType:sortReverse)" class="show-cursor">
<td>{{ item.fname }}</td>
...
</tr>
我不知道问题出在哪里?!
答案 0 :(得分:8)
您需要使用驼峰式案例,其订单 B y并未在您的控制器中订购 b y
var orderBy = $filter('orderBy');