Reputation: 9247
I have this autocomplete component:
<z-autocomplete class="z-autocomplete" *ngIf="!ipaddress.rinvapnId" (selectedChange)="onSelect($event)" [suggestion]="results" (searchEvent)="search($event)" [fieldname]="'addressname'" ></z-autocomplete>
In ts i have this:
search(e){
console.log(this.IPresults.includes(a=>a.apn==e.query),'aaa');
}
How to return all data from array that starts with that string ? something LIKE method in sql. Any suggestion?
Upvotes: 0
Views: 39
Reputation: 58523
All you need is filter
function :
return this.IPresults.filter(result => result.startsWith(e.query) );
Above snippet is just answer of
How to return all data from array that starts with that string ?
, you can do that many ways (e.g. regex) .Its all about how you implements the logic.
Upvotes: 2