Difficult question to put into words but basically I have an ng-option select box within an ng-repeat. In my current situation this causes the select box to appear 3 times as the option can be used on 3 different things.
难以理解的问题,但基本上我在ng-repeat中有一个ng-option选择框。在我目前的情况下,这会导致选择框出现3次,因为该选项可用于3种不同的事物。
If I select a value from the first select box then I need that to be removed from the other 2.
如果我从第一个选择框中选择一个值,那么我需要从另一个选择框中删除它。
Here is a JSFiddle with a primitive example of the issue
这是一个JSFiddle,其中包含该问题的原始示例
<select ng-options="item as item.name for item in test" ng-model="test.name">
jsFiddle: http://plnkr.co/edit/inrM2ZUOc7hEhSHgps9P?p=preview
Thanks in advance
提前致谢
1 个解决方案
#1
You can use a filter in the ng-repeat to exclude the selected options.
您可以在ng-repeat中使用过滤器来排除所选选项。
<select
ng-options="item as item.name for item in test | filter:'!'+selected"
ng-model="test.name">
#1
You can use a filter in the ng-repeat to exclude the selected options.
您可以在ng-repeat中使用过滤器来排除所选选项。
<select
ng-options="item as item.name for item in test | filter:'!'+selected"
ng-model="test.name">