问题
I have 2 multi select element and both get options from a variable list. If a variable selected as row variable it will not be shown in column select options. if user unselect option then variable should will shown in both list
$scope.variables = ['a','b','c','d','e','f'];
<select multiple ng-model="selectedAsRows" ng-options="v for v in variables"></select>
<select multiple ng-model="selectedAsCols" ng-options="v for v in variables"></select>
回答1:
I think that I understood what you want. Here is a fiddle with an example:
http://jsfiddle.net/26fZb/209/
The key is to use a custom filter like this one:
filter: { name: '!' + selectedAsFriend.name }
EDIT:
Here is your case with multiSelect. I have created custom filters.
app.filter('myFilter', function() {
return function(inputList, list) {
return inputList.filter(isAlreadySelected(list));
};
function isAlreadySelected(list){
return function(elem){
if (list.indexOf(elem) == -1)
return true;
else
return false;
}
}
});
Then to use it in the html file:
<select multiple ng-model="selectedAsRows" ng-options="v for v in variables | myFilter: selectedAsCols"></select>
<select multiple ng-model="selectedAsCols" ng-options="v for v in variables | myFilter: selectedAsRows"></select>
Take a look at the full code:
http://plnkr.co/edit/6eWZB75dAdquPD1jMmb7?p=preview
来源:https://stackoverflow.com/questions/33236247/2-multiple-select-and-single-option-list