I am trying to do a search with a bar, in which the names of all the clients that are registered in the bd appear. From a php file I made the query. This is my code ts:
userData:any={"accion":"consultaclientes"};
initializeItems() {
this.restprovider.Registro(this.userData).then((result) => {
this.data = result;
console.log(this.data);
this.clientes=this.data;
}, (err) => {
this.presentToast(err);
});
}
getItems(ev) {
// Reset items back to all of the items
this.initializeItems();
// set val to the value of the ev target
var val = ev.target.value;
// if the value is an empty string don't filter the items
if (val && val.trim() != '') {
this.clientes.nombre = this.clientes.nombre.filter((item) => {
return (item.toLowerCase().indexOf(val.toLowerCase()) > -1);
})
}
}
This my html code:
<ion-searchbar (ionInput)="getItems($event)"></ion-searchbar>
<ion-list>
<ion-item *ngFor="let item of items">
{{ item }}
</ion-item>