0
Pedido.ts :
getItems(ev: any) {
const val = ev.target.value;
if (val == '') {
this.clientes = null;
} else if(val && val.trim() != ''){
this.buscarUsuario(ev);
}
selectItem() {
this.clientes = this.clientes.filter((cliente) => {
this.pesquisa = cliente.cliente;
this.clientes = [];
})
buscarUsuario(ev: any) {
this.provider.buscarCliente().subscribe((cliente: Array<any>) => {
this.clientes = cliente;
console.log(this.clientes);
let val = ev.target.value;
if(val == this.clientes){
val = this.clientes
}
})
html request.
<ion-row >
<ion-col>
<ion-searchbar [(ngModel)]="pesquisa" (ionInput)="getItems($event)" formControlName="cliente" placeholder="Pesquisar"></ion-searchbar>
<ion-item *ngFor="let cliente of clientes">
<button ion-button (click)="selectItem()">{{cliente.cliente}}</button>
</ion-item>
</ion-col>
</ion-row>
Where do you boot
this.clientes
?– Renata
First I’ll explain my problem: I need to make a consultation to firebase, fetch the customers and bring to a vector. So far so good. The problem is, I can’t compare what’s being typed in the search bar with the client that’s in the array. I will edit my question. Thanks in advance
– user125721