我多次尝试从服务中填充ng-multiselect-dropdown,但均未成功。 有人可以帮我吗?
服务-----
getClients(): Observable<Client[]> {
return this.HttpClient.get<Client[]>('/api/clients');
}
组件-----
this.clientService.getClients()
.subscribe(data => {
this.dropdownList = data;
this.clientDropdownList.push({ '_id': data, 'name': data}) ,
console.log(this.dropdownList)
}
)};
html -----
<ng-multiselect-dropdown class="customDropdown"
formControlName="client"
[placeholder]="'Select Client'"
[data]="clientDropdownList"
[(ngModel)]="selectedItems"
[settings]="dropdownSettings"
(onSelect)="onItemSelect($event)"
(onSelectAll)="onSelectAll($event)">
</ng-multiselect-dropdown>
控制台日志------我有我的所有客户
(6) [{…}, {…}, {…}, {…}, {…}, {…}]
0: {_id: "5c5f8914b8e5a56058a4e16a", name: "*****randji", address:
"******", email: "*********", phone: "**********", …}
length: 6
__proto__: Array(0)
我只需要在下拉列表中填充客户的名称。
谢谢大家