当我以 react 形式使用 ng-select angular 时,出现此错误:
ERROR TypeError: selectedItems.map is not a function
我有 3 个选择,前两个工作得很好,但在第三个中我得到了错误!映射我正在使用该函数的项目(ng-select 在 *ngFor 内):
//for mappinig item :
mapLabelValueBS(objet) {
return objet.map(data => {
return {
id: data,
text: data.name
}
})
}
//this is the one that is causing the problem
<ng-select
[allowClear]="true"
[items]="mapLabelValueBS(filieres)"
placeholder="Filière non sélectionné"
(selected)="selecteFiliere($event)"
formControlName="filiere">
</ng-select>
我页面中的结果(当我点击该字段时它自身翻倍):
最佳答案
这个错误是在我传递 [items]="value"时出现的,其中值不是数组,所以请检查你是否没有将非数组元素传递给项目绑定(bind)。
关于javascript - Angular ng-select : selectedItems. map 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54709527/