我正在尝试实现链式选择,但链条无法正常工作。
http://plnkr.co/edit/ndm7PFGK8akdaHra7Fdm?p=preview
我想要什么,需要:例如当选择'alpargatas'作为类别,并选择任何列出的品牌时,该类别仍应选择为'alpargatas'或选择'Calvin Klein'作为品牌,并且选择任何列出的类别时,品牌仍应选择为' Calvin Klein'。
任何解决方案,提示或建议?!事先提前
答案 0 :(得分:1)
您需要按正确的顺序使用filter。
category
下拉列表
brand
filter:{brand: filterObject.brand}: true//pass true for strict mode
添加过滤条件
unique
过滤器,例如unique: 'category'
orderBy
过滤器,如orderBy:'category'
在HTML
中,它看起来像是
<select ng-model="filterObject.category"
ng-options="c.category as c.category for c in shoes|filter:{brand: filterObject.brand}: true| unique: 'category'| orderBy:'category'">
<option value="" ng-value="undefined">-- Category:</option>
类似于Brand
下拉列表
<select ng-model="filterObject.brand"
ng-options="b.brand as b.brand for b in shoes|filter:{category: filterObject.category}: true| unique: 'brand'| orderBy:'brand'">
<option value="" ng-value="undefined">-- Brand:</option>
看看dropdowns
与主数据源$scope.shoes
绑定,因此您不需要控制器中的其他过滤器。
检查更新后的plunk
注意正如@ m59所提到的,当您在寻找答案时,不应该删除您的帖子。