简体   繁体   English

根据第一个选择过滤掉第二个下拉菜单。

[英]Filter out second drop-down based on first selection.

I want the second dropdown not to contain the first selection. 我希望second dropdown不包含第first选择。 If i select "Team1" in first dropdown, the second one should not contain "Team1" and to contain the other ones. 如果我在第一个下拉列表中选择"Team1" ,则第二个不应包含"Team1" and to contain the other ones. The same to happen vice-versa too. 反之亦然。

<div ng-app>
    <div ng-controller="TodoCtrl">
    <select ng-model="name" ng-options="f.name for f in devices"></select>
    <select ng-model="name" ng-options="f.name for f in devices 
               | filter:{id:name.id }" id="{{formEach.id}}">
        </select>
    </div>
</div>

Below is a fiddle which address the problem http://jsfiddle.net/x40ese02/ 下面是一个小提琴,解决了这个问题http://jsfiddle.net/x40ese02/

Change your filter to filter:{id:'!' + name.id} 将您的过滤filter:{id:'!' + name.id}更改为以下filter:{id:'!' + name.id} filter:{id:'!' + name.id} . filter:{id:'!' + name.id}

 function TodoCtrl($scope) { $scope.devices = [{ id: "X000", name: 'Team 1', icon: 'ion-document-text', status: 'Owner', color: 'brown' }, { id: "X002", name: 'Team 2', icon: 'ion-document-text', status: 'Owner', color: 'yellow' }, { id: "X003", name: 'Team 3', icon: 'ion-document-text', status: 'Owner', color: 'black' }]; } 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app> <div ng-controller="TodoCtrl"> <select ng-model="name" ng-options="f.name for f in devices"></select> <select ng-model="name2" ng-options="f.name for f in devices | filter:{id: '!' + name.id }" id="{{formEach.id}}"> </select> </div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM