No max selected option for multiple select
Is there something I'm missing? It might be extremely useful to include a max-selected option so you can limit how many items a user can select. I'm trying to hack around this to do it, but nothing is really working.
I'm running into the same issue. We want to have a multiselect with a high end limit. If this is something we would like to see in the project (angular-strap) proper I can give it shot when I get back next week.
I have this working I modified the directive a bit. Changed the watch for model a bit.
Old Directive Watch:
// Watch model for changes
scope.$watch(attr.ngModel, function(newValue, oldValue) {
// console.warn('scope.$watch(%s)', attr.ngModel, newValue, oldValue);
select.$updateActiveIndex();
controller.$render();
}, true);
Modified Directive Watch:
// Watch model for changes
scope.$watch(attr.ngModel, function(newValue, oldValue) {
// console.warn('scope.$watch(%s)', attr.ngModel, newValue, oldValue);
if(attr.limit < newValue.length){
for(var i = 0; i < newValue.length; i++){
if(i >= oldValue.length) break;
if(!angular.equals(newValue[i], oldValue[i])) break;
}
if(i === newValue.length){
newValue.pop();
}else{
newValue.splice(i, 1);
}
}
select.$updateActiveIndex();
controller.$render();
}, true);
Can anyone tell me if this is where they expect the change would be made? Should I be doing this in the $select provider instead (not sure I have old and new values there although)?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.