Search code examples
angularangular6dropdown

How to set default selected checkbox in Ng Multiselect dropdown (Angular Control)


Here is the sample code, to create multiselect dropdown

<ng-multiselect-dropdown [placeholder]="'Select'"
                   [data]="dropdownList"
                   [(ngModel)]="selectedItems"
                   [settings]="dropdownSettings"
                   (onSelect)="onItemSelect($event)"
                   (onSelectAll)="onSelectAll($event)">
</ng-multiselect-dropdown>

while creating this multiselect dropdown, i wanted few of the check boxes to be selected by default (based on the data provided). I tried binding the checkboxes using [(ngModel)]="selectedItems" property, but it doesn't seems to be working.


Solution

  • Can you paste selectedItems, dropdownList and dropdownSettings object?

    SelectedItems and dropdownList items should be same and dropdownSettings should be having the correct idField and textField.