我正试图从客户端服务中填充ng-multiselect-dropdown,我可以从数据库中获取客户端,但是我不知道发送ID和名称以填充列表的正确语法!
我已经尝试了很多例子,但是都没有成功,
到目前为止我尝试过的是:
this.dropdownList =
this.clientService.getClients().subscribe(
data => this.clients = data,
error => console.log(error),
() => this.isLoading = false
)};
这是我的服务文件
getClients(): Observable<Client[]> {
return this.HttpClient.get<Client[]>('/api/clients');}
型号:
export class Client {
_id?: string;
name?: string;
address?: string;
zipcode?: number;
city?: string;
email?: string;
phone?: string;
}
HTML:
<ng-multiselect-dropdown
[placeholder]="'custom placeholder'"
[data]="clients"
[selectedItems]=selectedItems;
[settings]="dropdownSettings"
(onSelect)="onItemSelect($event)"
(onSelectAll)="onSelectAll($event)"
>
</ng-multiselect-dropdown >
[Populated with [data]= clients[https://imgur.com/a/D1WFMlw]
我希望有一个函数(this.dropdownList =)并从服务中填充我的列表。到目前为止,我已经填充了一个clients对象列表,我需要填充客户端名称和id :)
谢谢大家。