Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excluding selected items
Message
 
 
À
27/10/2015 05:53:51
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01626449
Message ID:
01626487
Vues:
28
>>Hi everybody,
>>
>>I found this link http://christian.fei.ninja/Angular-Filter-already-selected-items-from-ng-options/
>>
>>I've defined the following so far:
>>
>>
>><div class="col-md-4">
>>                <select class="form-control" ng-model="newLink.groupNo"
>>                        name="groupNo" id="groupNo" 
>>                        ng-options="t.value as t.text for t in metaData.spGroups"></select>
>>            </div>
>>
>>I need to only allow to select groups which are not already in the $scope.currentSChannels.scgsLink.groupNo column.
>>
>>I originally tried
>>
>>
>>| filter:{ value : !currentSChannels.scsgLink.groupNo }
>>
>>but then my drop down came empty.
>>
>>I see in the blog by that author that he implements custom excludeFrom filter and passes an array of things. But how exactly that works? Does it check each value from all columns in the first array against values in all columns of the second array? How can I change the above to make sure that only value (or newLink.groupNo) is checked against groupNo column and not all other columns of the array are checked?
>>
>>Thanks in advance.
>
>Only took a quick look at the link but he's only looking for one value to exclude. IIRC, If you need to filter against an array you would need to use a predicate function. This gets called for each item in the array - check whether item exists in the $scope.currentSChannels.scgsLink.groupNo list and return true/false accordingly

I'll research what does it mean predicate function. For now I implemented the following solution:

http://stackoverflow.com/questions/33353071/angularjs-exclude-already-selected-items-from-array/33353269#33353269
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform