在NG-选项NG-重复我怎么更新模型不包括从另一个选择框选定值 [英] ng-option within ng-repeat how do I update the model not to include a selected value from another select box

查看:178
本文介绍了在NG-选项NG-重复我怎么更新模型不包括从另一个选择框选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题很难用语言来表达,但基本上我有一个NG重复内的NG选项选择框。在我目前的情况这将导致选择框出现3次为选项可以在3个不同的东西被使用。

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.

如果我选择第一个选择框中的值,然后我需要的是从其他2拆除。

If I select a value from the first select box then I need that to be removed from the other 2.

下面是一个的jsfiddle这个问题的一个基本的例子

Here is a JSFiddle with a primitive example of the issue

<select ng-options="item as item.name for item in test" ng-model="test.name">

的jsfiddle: http://plnkr.co/编辑/ inrM2ZUOc7hEhSHgps9P?p = preVIEW

在此先感谢

推荐答案

您可以在NG-重复排除所选的选项使用过滤器。

You can use a filter in the ng-repeat to exclude the selected options.

plunkr

<select 
  ng-options="item as item.name for item in test | filter:'!'+selected"
  ng-model="test.name">

这篇关于在NG-选项NG-重复我怎么更新模型不包括从另一个选择框选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆