hi guys,
I am new in ionic 2,
I have created a “search bar” and it is working as expected when searching list
but when I clicking 'cancel ’ or 'x ’ button function throwing error ERROR TypeError: Cannot read property ‘trim’ of undefined
I want to show my full list when I click 'cancel ’ or 'x ’ button
please help
here is my code:
page.html:
<ion-searchbar *ngIf="toggled" [(ngModel)]="searchstudent" [showCancelButton]="true" cancelButtonText="close"
(ionInput)="getFilteredItem($event)" (ionClear)="cleared()" (ionCancel)="onCancel()"></ion-searchbar>
page.ts:
getFilteredItem(searchbar) {
var item = searchbar.target.value;
this.paneList = this.items.filter((data) => {
return (data.EmployeeName.toLowerCase().indexOf(item.trim().toLowerCase()) > -1);
});
}
onCancel(){
this.toggled=false;
return this.paneList;
}
cleared(){
return this.paneList;
}