我尝试传递$routeParams
值来过滤ng-repeat数据。这是我的控制器:
myApp.controller('BookCtrl', ['$scope', '$routeParams' function($scope, $routeParams) {
$http.get('books.json').success(function(data) {
$scope.books = data;
$scope.slug = $routeParams.slug;
});
}]);
我的HTML:
<div class="container" role="document" ng-repeat="book in books | filter:{slug: {{slug}}}">
<p>{{book.title}}</p>
</div>
可以这样做吗?我尝试使用上面的代码,但返回了语法错误:
答案 0 :(得分:0)
问题已解决:
<div class="container" role="document" ng-repeat="book in books | filter:{slug: slug }">