我正在尝试使用 ngl-lightning 库的 ngl-lookup 我想传递一个 any[] 类型的数组而不是 String[],这是我的代码:
<ngl-lookup [lookup]="lookupManagerUsers" [icon]="true" [image]="'user'" [noResultsText]="'Aucun résultat trouvé'"
[(pick)]="pickedManagerUser" (pickChange)="managerUserPicked($event)" placeholder="Recherchez un agent..." formControlName="manager_id"
ngDefaultControl>
<ng-template nglLookupItem let-item>
<div class="slds-media__body">
<span class="slds-media__figure slds-listbox__option-icon">
<span class="slds-icon_container slds-icon-standard-user">
<svg class="slds-icon slds-icon_small" aria-hidden="true">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#user" />
</svg>
</span>
</span>{{item}}
</div>
</ng-template>
</ngl-lookup>
这是我的方法
pickedManagerUser: string = '';
lookupManagerUsers = (query: string, source = this.manager_users): any[] => {
let temp = [];
if (!query) {
temp = source;
} else {
const temp2 = source.filter(user => user.first_name.indexOf(query.toLowerCase()) > -1 || user.last_name.indexOf(query.toLowerCase()) > -1);
for (const m of temp2) {
temp.push(m);
}
}
return temp;}
managerUserPicked(superhero) {
console.log(superhero); }
请有任何帮助