角ng-multiselect-dropdown用对象数组填充

时间:2019-06-03 16:42:43

标签: angular ng-dropdown-multiselect

这是我在html中用于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>

当前,dataMarcas返回一个数组:

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

但是现在我必须用这样的数组填充下拉列表:

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

我必须用name属性填充它。我该怎么办?

1 个答案:

答案 0 :(得分:0)

您可以在textField: 'name'中加入dropdownSettingsng-multiselect-dropdown