Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-multiselect-dropdown - TypeError: Cannot read property 'idField' of undefined

Followed steps as per https://www.npmjs.com/package/ng-multiselect-dropdown for angular 9

received below error in browser console

TypeError: Cannot read property 'idField' of undefined

like image 953
Shyam Avatar asked Apr 12 '20 18:04

Shyam


3 Answers

I had the same issue and I solved but moving [settings] param prior to [data] para.

Example:

    <ng-multiselect-dropdown
        [settings]="dropdownSettings"
        [data]="dropdownList"
        [(ngModel)]="selectedItems"
    >
    </ng-multiselect-dropdown>
like image 131
Abraham Cm Avatar answered Nov 19 '22 22:11

Abraham Cm


Please set

dropdownSettings:IDropdownSettings = {
..Other settings,
idField: 'id',
textField: 'text'};

set your dropdown list as

dropdownList= [{id: '1', text: 'Sample Text'}, ..]

Also set [settings] before [data] in html as indicated by Abraham Cm

like image 3
Baaji Shaik Avatar answered Nov 19 '22 23:11

Baaji Shaik


yes, solution above (with [settings] binding before [data]) works because ng-multiselect-dropdown has setters in data and settings inputs. data setter is using settings input. So in this case order is important. It also suprised me at the beginning. Look at source code: enter image description here

like image 2
Potwór z Lochness Avatar answered Nov 19 '22 22:11

Potwór z Lochness