ersidam
ersidam

Reputation: 23

2 multiple select and single option list

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>

Upvotes: 0

Views: 118

Answers (1)

Ignacio Villaverde
Ignacio Villaverde

Reputation: 1264

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

Upvotes: 2

Related Questions