Searching and selecting clients with the search bar - Ionic

1

I type a client in the search bar, it traverses the vector, brings its clients in a list, so far so good.

The problem: When I have two clients with the same initial characters , it brings to the search field (ALWAYS) the last element of the array, even though I choose the first one.

Follow the code:

 selectClientes() {
  this.clientesList = this.clientesList.filter((cliente) => {   
    this.pedido.cliente = cliente.cliente;
    this.clientesList = [];
})

html:

  <ion-row>
    <ion-col>
      <ion-searchbar [(ngModel)]="pedido.cliente" (ionInput)="getClientes($event)" formControlName="cliente" placeholder="Pesquisar"></ion-searchbar>
    </ion-col>
  </ion-row>
<ion-list>
    <ion-item *ngFor="let element of clientesList" (click)="selectClientes(element)">      
        {{element.cliente}}        
 </ion-item> 
</ion-list>
    
asked by anonymous 15.10.2018 / 20:34

0 answers