ng multi select下拉菜单中看不到数据

时间:2019-04-05 05:44:39

标签: angular

数据在对象中。当我将其映射到ng multiselect dropdown.value时,下拉列表中未显示该值。.angular7

<div class="form group mltslt" *ngIf="individual==true">
    <label for="code">Select Student(s) by Register Number </label>
    <ng-multiselect-dropdown name="subjecs" [data]="dropdownList" [(ngModel)]="selectedItems" 
[settings]="dropdownSettings" 
(onSelect)="onItemSelect($event)" 
(onDeSelect)="OnItemDeSelect($event)"
(onSelectAll)="onSelectAll($event)"
(onDeSelectAll)="onDeSelectAll($event)" required></ng-multiselect-dropdown>
<br>

enter image description here

2 个答案:

答案 0 :(得分:0)

https://www.npmjs.com/package/ng-multiselect-dropdown

如文档所示。您需要在设置中定义textField属性以指向数据中的名称。

因此解决方案应该是

this.dropdownList = [
   { id: 1, itemName: 'Mumbai' },
];
this.dropdownSettings = {
  singleSelection: false,
  idField: 'id',
  textField: 'itemName', <--- IMPORTANT, NEEDS TO MATCH THE PROPERTY OF THE NAME IN THE DATA GIVEN
  selectAllText: 'Select All',
  unSelectAllText: 'UnSelect All',
};

答案 1 :(得分:0)

使用[(ngModel)] =“ selectedUCID”将选择可见的下拉列表。

this.selectedUCID = ucid;