Search code examples
angularjsbootstrap-multiselect

TypeError: collection.some is not a function


angular.js:13424 TypeError: collection.some is not a function
at findIndex (angularjs-dropdown-multiselect.min.js:1)
at Scope.$scope.isChecked (angularjs-dropdown-multiselect.min.js:1)
at angularjs-dropdown-multiselect.min.js:1
at Object.forEach (angular.js:321)
at Scope.$scope.getButtonText (angularjs-dropdown-multiselect.min.js:1)
at fn (eval at compile (angular.js:14268), :4:230)
at expressionInputWatch (angular.js:15321)
at Scope.$digest (angular.js:16860)
at Scope.$apply (angular.js:17133)
at done (angular.js:11454)

Here's the plunker to show the error

https://plnkr.co/edit/SqZGFwf4iD09MqLiisPK?p=preview

So the issue really seems to be with setting value to model where if I set it to an object I see this error. I wanted to have to as single select hence the object instead of an array.


Solution

  • I didn't realize that what you wanted for first multi select boxes - for them to be single select. But if you check documentation it's clear that you are missing settings selectionLimit, you are right about model being object for one only selection:

    "model": {
                "id": 1
            },
            "settings": {
                "smartButtonMaxItems": 1,
                selectionLimit: 1
            }
    

    New plunker: https://plnkr.co/edit/uCBYPG3JCp1v2ECnr6up?p=preview

    Forgot to mention, I also updated angular-dropdown-multiselect.js with latest one from github.