Nithesh P
Nithesh P

Reputation: 51

data are not visible on ng multi select drop down

the data is in object .when i map that to ng multiselect dropdown.value not showing in drop down..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

Upvotes: 0

Views: 4932

Answers (2)

Dilli
Dilli

Reputation: 79

using [(ngModel)]="selectedUCID" it will select visible the dropdown.

this.selectedUCID=ucid;

Upvotes: 0

Qellson
Qellson

Reputation: 552

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

As seen in the documentation. You need to define in the settings the textField property to point to the name in the data.

So the solution should be

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',
};

Upvotes: 2

Related Questions