Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs ng单击不在ng内工作重复_Angularjs_Angularjs Scope_Angularjs Ng Repeat - Fatal编程技术网

Angularjs ng单击不在ng内工作重复

Angularjs ng单击不在ng内工作重复,angularjs,angularjs-scope,angularjs-ng-repeat,Angularjs,Angularjs Scope,Angularjs Ng Repeat,我正试图显示基于品牌的产品,但ng在内部点击ng重复不起作用。 但是ng在ng repeat工作正常。ng repeat内部是否存在冲突…? 模块 var myApp = angular.module('myapplication', ['ngRoute', 'ngResource','uiSlider']); 我的观点 <a style="cursor:pointer" ng-click="Brandfilters = ''">All Brands</a> <

我正试图显示基于品牌的产品,但ng在内部点击ng重复不起作用。 但是ng在ng repeat工作正常。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);
        };
}])   
myApp.controller(“StoreListCtr”[“$scope”、“$http”、“$resource”、“$location”,
函数($scope、$http、$resource、$location){
$scope.products=products.query();
$scope.Brandfilters=null;
$scope.lower_价格=100;
$scope.upper_价格=500;
$scope.priceRange=功能(产品){
退货(产品['cost']>=$scope.lower\u价格
&&产品['cost']试试看

<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> 

{{产品.品牌}

ng repeat中的代码是经过计算的代码,因此不必使用{{}

<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> 

{{产品.品牌}
工作示例-

试试这个-

替换-

<a style="cursor:pointer" ng-click="Brandfilters='{{product.brand}}'">{{product.brand}}</a>

您可能需要将正确的指令注入模块,可能是
'ui.directives'
,也可能是
ui.utils

var myApp = angular.module('myapplication', 
                               ['ngRoute', 'ngResource','uiSlider', 'ui.directives']); 
查看文档时,您可能需要
ui.utils

var myApp = angular.module('myapplication', 
                               ['ngRoute', 'ngResource','uiSlider', 'ui.utils']); 

请参阅参考资料。

它应该在索引页上显示的产品中充当过滤器…如果我的解决方案不起作用,请尝试在plunker中复制您的错误。这样做会更容易帮助您。您是否可以尝试将ng repeat中的ng click替换为:alert(product.brand)并告诉我们它是如何工作的?删除花括号和单引号:
ng click=“Brandfilters=product.brand”
您的
模块是什么样子的?不,它不工作。它显示了类似“Microsoft”的内容你们在控制台中遇到了什么错误?请检查并分享你们的错误。你们能创建一个JSFIDLE吗?这样我就可以了解更多。它对我有用。请检查这个-
var myApp = angular.module('myapplication', 
                               ['ngRoute', 'ngResource','uiSlider', 'ui.directives']); 
var myApp = angular.module('myapplication', 
                               ['ngRoute', 'ngResource','uiSlider', 'ui.utils']);