可以将routeparam设置为要在过滤器中使用的变量吗?我不相信我的格式正确。我沿着URL传递它,但似乎无法正常使用它。我需要这个工作,因为我似乎无法获得如下所述的核心REST调用过滤:Filter AngularJS REST JSON Data: error:badcfg Response does not match configured parameter
示例:
控制器:
pfcControllers.controller('pfcCategoriesCtrl', ['$scope', '$routeParams', 'pfcArticleCategories', function ($scope, $routeParams, pfcArticleCategories) {
$scope.category = pfcArticleCategories.query();
$scope.articlecategoryID = { articlecategoryID: $routeParams.articlecategoryID };
}]);
过滤器:
<table class="table table-striped">
<tr>
<th>ID</th>
<th>Title</th>
<th>Category ID</th>
<th>Link</th>
</tr>
<tr ng-repeat="articles in category | filter:{articlecategoryid:'articlecategoryID'} | orderBy:articleSortOrder">
<td>{{articles.id}}</td>
<td>{{articles.articletitle}}</td>
<td>{{articles.articlecategoryid}}</td>
<td><a ng-href="#article/{{article.id}}/{{article.articletitle}}">{{article.articletitle}}</a></td>
</tr>
</table>
来自其他网页的链接:
<a ng-href="#categories/1">Category 1</a>
App.JS路线:
when('/categories/:articlecategoryID', { templateUrl: './views/categories.html', controller: 'pfcCategoriesCtrl' }).
答案 0 :(得分:1)
我认为这可行。
pfcControllers.controller('pfcCategoriesCtrl', ['$scope', '$routeParams', 'pfcArticleCategories', function ($scope, $routeParams, pfcArticleCategories) {
$scope.category = pfcArticleCategories.query();
$scope.articlecategoryID = $routeParams.articlecategoryID;
}]);
删除articlecategoryID
周围的引号<tr ng-repeat="articles in category | filter:{ articlecategoryid: articlecategoryID } | orderBy:articleSortOrder">