2017-10-28 32 views
0
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) 

這裏的plunker顯示錯誤類型錯誤:collection.some不是一個函數

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

所以這個問題確實似乎是與設定值,以模型,其中,如果我將它設置成對象我看到這個錯誤。我想不得不作爲單個選擇因此而不是數組。

+0

從哪裏得到這樣的:angularjs,多選,dropdown.js文件? –

+0

plunker庫angularjs-multiselect-dropdown –

+0

@RakeshBurbure另外我在我的本地使用https://github.com/dotansimha/angularjs-dropdown-multiselect得到相同的錯誤 –

回答

0

我沒有意識到,你想要的第一個多選框 - 他們是單選。 但是,如果你檢查文檔很顯然,你缺少的設置selectionLimit,你說得對模式是一個只有選擇對象:

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

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

忘了提,我也更新角-dropdown-multiselect.js與來自github的最新版本。

+0

如果您要查看文檔(http://dotansimha.github.io/angularjs-dropdown-multiselect/docs/#/main),您會看到對於「單一選擇限制」,模型需要是一個對象,不是一個數組。 前兩個下拉應該是單選。通過使它成爲一個數組,它變成了多選。 –

+0

對不起,我沒有意識到你想要前兩個選擇框不是多選,我更新了答案。 – pegla

0

我認爲問題是與圖書館本身在哪裏檢查一個對象的array.some事件。

我加入這個檢查解決了該問題 '角下拉-multiselect.js'

if(toString.call(collection)=="[object Array]") 
相關問題