pmiranda
pmiranda

Reputation: 8420

Angular ng-multiselect-dropdown populate with an array of objects

This is my code in the html for a ng-multiselect-dropdown:

<div class="form-group" *ngIf="paisActivo != '-1'">
    <ng-multiselect-dropdown
            [placeholder]="'[Seleccione Marca]'"
            [data]="dataMarcas"
            [(ngModel)]="adminTresActivos"
            [settings]="dropdownSettings"
            (onSelect)="onItemSelect($event)"
            (onDeSelect)="onItemDeSelect($event)"
            [class]="'form-control custom-form-control'"
    >
    </ng-multiselect-dropdown>
</div>

Currently, dataMarcas returns an array:

marcas: [
    'ABC',
    'XYD',
    'ETC',
]

But now I have to populate the dropdown with an Array like this:

[
  {icon: "aquiles.png", id: 853, name: "AQUILES"},
  {icon: "arkan.png", id: 855, name: "ARKAN"}.
  etc
]

I have to populate it with the name property. How can I do it?

Upvotes: 1

Views: 3079

Answers (1)

blapaz
blapaz

Reputation: 334

You can include textField: 'name' in your dropdownSettings. ng-multiselect-dropdown

Upvotes: 1

Related Questions