我试图显示基于品牌的产品,但ng-repeat内的ng-click不起作用。 但ng-click在ng-repeat之外工作正常。 ng-repeat内部有冲突吗?ng-click不能在ng-repeat内工作
模块
var myApp = angular.module('myapplication', ['ngRoute', 'ngResource','uiSlider']);
我的视图
<a style="cursor:pointer" ng-click="Brandfilters = ''">All Brands</a>
<div class="list-group-item" ng-repeat="product in products | unique: 'brand'" >
<a style="cursor:pointer" ng-click="Brandfilters='{{product.brand}}'">{{product.brand}}</a>
</div>
我的控制器
myApp.controller("StoreListCtr", ['$scope', '$http', '$resource', '$location',
function($scope, $http, $resource, $location) {
$scope.products = Products.query();
$scope.Brandfilters = null;
$scope.lower_price = 100;
$scope.upper_price = 500;
$scope.priceRange = function(products) {
return (products['cost'] >= $scope.lower_price
&& products['cost'] <=$scope.upper_price);
};
}])
它应该充当产品在索引页上显示的过滤器... –
如果我的解决方案无法正常工作,请尝试在重新生成时重现您的错误。以这种方式帮助你会更容易。 – Okazari
你可以尝试用ng:repeat(product.brand)代替ng-repeat,并告诉我们它的行为如何? – Okazari