Hello i made a ionic searchbar script returns the items[] ok but i want to connect it with my php authservice and return the results from a php function.
I already connected my app with the authservice and i have returned JSON data in other pages so the authservice works fine i just don't know how to put the php function in here
this.items = [
{ title: 'one' },
{ title: 'two' },
{ title: 'three' },
{ title: 'four' },
{ title: 'five' },
{ title: 'six' }
];
this is what i've done so far.
searchPage.ts
@Component({ selector: "page-search", templateUrl: "search.html" })
export class SearchPage {
items: any;
filtereditems: any;
searchTerm: string = '';
public noRecords: boolean;
constructor(
public common: Common,
public navCtrl: NavController,
public app: App,
public menu: MenuController,
public authService: AuthService,
platform: Platform,
statusBar: StatusBar,
splashScreen: SplashScreen
) {
this.items = [
{ title: 'one' },
{ title: 'two' },
{ title: 'three' },
{ title: 'four' },
{ title: 'five' },
{ title: 'six' }
];
this.filtereditems = [];
}
filterItems() {
console.log(this.searchTerm);
this.filtereditems = this.items.filter((item) => {
return item.title.toLowerCase().indexOf(this.searchTerm.toLowerCase()) > -1;
});
}
searchPage.html
<ion-header> <ion-navbar> <button ion-button menuToggle> <ion-icon name="menu"></ion-icon> </button> <ion-toolbar color="primary"> <ion-searchbar [(ngModel)]="searchTerm" (ionInput)="filterItems()"> </ion-searchbar> </ion-toolbar> </ion-navbar> <ion-content padding> <ion-grid ion-fixed no-padding> <ion-list style="position: absolute;z-index:1;width:100%;"> <ion-item *ngFor=" let item of filtereditems" color="silver">
{{item.title}}
</ion-item> </ion-list> </ion-grid> </ion-content>
Any hint?