按阵列

时间:2017-03-01 10:40:07

标签: javascript angularjs

我想过滤一个数组的ng-options。例如:

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

我该怎么做?

1 个答案:

答案 0 :(得分: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>