angular - How to find out which ngl-lookup was clicked on? -
i'm generating ngl-lookup's in loop. each ngl-lookup have drop down define source of lookup function. example, if user selects drop down value "cat", want display in ngl-lookup cats names. second ngl-lookup list, if user selects "dog", dogs names should displayed.
i trying provide object id lookup function i'm not getting query i'm entering search field.
also, once i've chosen value suggestion list, perform additional logic.
any idea on how solve angular 4?
this doesn't work:
<div *ngfor="let myobject of myobjects"> <ngl-lookup [lookup]="lookup(myobject.id)" [(pick)]="onpick(myobject.id, selectedvalue)" debounce="0" placeholder="search"> </ngl-lookup> </div>
angular component:
lookup(query: string, objectid: number): string[] { if (!query) { return null; } let myobject = this.myobjects.find(x => x.id === objectid); return myobject.values.filter((d: string) => d.tolowercase().indexof(query.tolowercase()) > -1); } onpick(objectid: number, selectedvalue: string) { this.myobjects.find(x => x.id === objectid).value = selectedvalue; this.performadditionallogic(); }
<ngl-lookup [lookup]="lookup(myobject.id)" [(pick)]="onpick(myobject.id, selectedvalue.value)" debounce="0" placeholder="search" #selectedvalue> </ngl-lookup> // try using template reference
sorry bad edit on mobile
wiki
Comments
Post a Comment