2017-03-01 114 views
-1

我想过滤一个数组的ng选项。举例:按数组筛选Angular JS ng选项

<select 
    ng-model="currentItem.Community.white_label_id" 
    ng-options="whitelabel.WhiteLabel.id as whitelabel.WhiteLabel.name for whitelabel in whitelabels | filter:whitelabel.WhiteLabel.id in currentWhiteLabel.affiliatedids" 
> 

currentWhiteLabel.affiliatedids看起来像[73,71]

我怎样才能做到这一点?

+0

你能够分享一些示例数据吗? – Ankh

+0

whitelabels是一个数组,例如{“WhiteLabel”:{“id”:28,“name”:“abd”,“code”:“abc”,“type”:“collectivity”,“active”:true,嵌入 “:假的,” 子域 “:””, “网站”: “http://dqsfsdf.com”, “help_website”:空, “email_auto”: “[email protected]”}}。 Ng选项很好,但是我不能用数组来过滤它们 – Cby

回答

0

好的我找到了一个解决方案,但在选项中使用了ng-repeat。希望这将有助于某人:

option value="whitelabel.WhiteLabel.id" ng-repeat="whitelabel in whitelabels" ng-if="currentWhiteLabel.affiliatedids.indexOf(whitelabel.WhiteLabel.id) != -1">{{whitelabel.WhiteLabel.name}}</option>