我希望second dropdown
不包含first
选项。如果我在第一个下拉列表中选择"Team1"
,则第二个下拉列表不应包含"Team1" and to contain the other ones.
。反之亦然。
<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>
以下是解决问题的小提琴 http://jsfiddle.net/x40ese02/
答案 0 :(得分:0)
将过滤器更改为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>