2017-03-01 69 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>