TypeError: collection.some is not a function

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)

这是显示错误的插件

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

所以问题似乎确实与设置模型的值有关,如果我将它设置为一个对象,我会看到这个错误。我想必须作为单个 select 因此对象而不是数组。

我没有意识到你想要第一个多 select 盒子 - 让它们成为单个 select。 但是,如果您查看文档,很明显您缺少设置 selectionLimit,您认为模型仅针对一个对象是正确的 selection:

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

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

忘了说了,我还用 github.

的最新更新了 angular-dropdown-multiselect.js

我认为问题出在库本身,它检查对象的 array.some 事件。

我通过将此检查添加到 'angular-dropdown-multiselect.js'

来解决问题
if(toString.call(collection)=="[object Array]")