in file HTML
<ion-searchbar placeholder="Username" type="text" (ionInput)="getTopics($event)" [showCancelButton]="shouldShowCancel" (ionCancel)="onCancel($event)"></ion-searchbar>
<ion-item *ngFor="let item of items">
<ion-avatar item-left="item-left">
<img [src]="item.avatar"></ion-avatar>
<ion-label> {{item.name}}</ion-label>
</ion-item>
in file TS
export class AddChatPage {
items: any[];
constructor(public navCtrl: NavController,
public navParams: NavParams ) {
this.generateTopics();
}
generateTopics() {
this.items = [
{ name: 'amr mohy', avatar: '/assets/imgs/6.png' },
{ name: 'mando fady', avatar: '/assets/imgs/5.png' }
]
}
getTopics(ev: any) {
this.generateTopics();
let serVal = ev.target.value;
if (serVal && serVal.trim() != '') {
this.name= this.name.filter((topic) => {
return (topic.toLowerCase().indexOf(serVal.toLowerCase()) > -1);
})
}
}
}