Hi,
I read in Ionic doc and on the web that you can easily filter an array by using filter(). Something like
return this.items.filter((v) => {
if(v.toLowerCase().indexOf(q.toLowerCase()) >= 0) {
return true;
}
return false;
})
But what if the "items" is an array of objects?
What I have done seems to work, but I thought it could be nicer than that:
let newList : IInfo[] = new Array<IInfo>;
for (let idx = 0; idx < this.myList.length; idx++) {
if (myList[idx].id.indexOf(str) >= 0)
newList.push(this.myList[idx]);
else if (myList[idx].name.indexOf(str) >= 0)
newList.push(this.myList[idx]);
else if (myList[idx].position.indexOf(str) >= 0)
newList.push(this.myList[idx]);
})
Do you have other better suggestion?