'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



Solution 1:[1]

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

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Baaji Shaik
Solution 2 Potwór z Lochness