Angular 按多个复选框和属性问题过滤
Angular Filter by multiple Checkboxes and properties issue
我正在尝试使用 Angular.js 中 json 输出的一些属性进行过滤,这是我的 plunker link.
实际问题是,如果我尝试按类型 1 进行过滤,它会自动检查颜色过滤器值,我希望两个过滤器应该单独应用或组合应用。
我希望将此过滤器应用于电子商务网站,以选择品牌、类别、最低和最高价格等。
这个过滤函数应该怎么写angular.
问题是您在 两种不同类型的复选框中使用了相同的 checked
属性 和 ng-model
ng-checked="person.checked" ng-model="person.checked"
相反,您应该使用两个不同的模型,例如 person.checked.type
和 person.checked.color
,应该是这样的:
//in type checks
<input type="checkbox" ng-checked="person.checked.type" ng-model="person.checked.type"/> {{ person.type }}
//in color checks
<input type="checkbox" ng-checked="person.checked.color" ng-model="person.checked.color" {{ person.color }}
更新
Here 是一个工作的 plunker
我正在尝试使用 Angular.js 中 json 输出的一些属性进行过滤,这是我的 plunker link.
实际问题是,如果我尝试按类型 1 进行过滤,它会自动检查颜色过滤器值,我希望两个过滤器应该单独应用或组合应用。
我希望将此过滤器应用于电子商务网站,以选择品牌、类别、最低和最高价格等。
这个过滤函数应该怎么写angular.
问题是您在 两种不同类型的复选框中使用了相同的 checked
属性 和 ng-model
ng-checked="person.checked" ng-model="person.checked"
相反,您应该使用两个不同的模型,例如 person.checked.type
和 person.checked.color
,应该是这样的:
//in type checks
<input type="checkbox" ng-checked="person.checked.type" ng-model="person.checked.type"/> {{ person.type }}
//in color checks
<input type="checkbox" ng-checked="person.checked.color" ng-model="person.checked.color" {{ person.color }}
更新
Here 是一个工作的 plunker