Search code examples
angularsalesforce-lightningng-lightning

How to pass array of type any to a Lookup


I am trying to use ngl-lookup of the ngl-lightning library i want to pass an array of type any[] instead of String[], this is my code:

 <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>

and this is my method 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); }

but this is really my problem : enter image description here

any help please


Solution

  • Try to print a specific property instead of the whole item, ie {{ item.first_name}} instead of the whole item as {{ item }}.