Поиск Ionic 3 не показывает список после очистки панели поиска и как искать в другой категории? - PullRequest
0 голосов
/ 23 мая 2019

Поиск не показывает список после очистки панели поиска.Сначала я делаю поиск по названию клиники, затем я хочу искать по названию страховки.Как это сделать?У меня есть две функции в API, но эта функция, во-первых, заключается в поиске по названию клиники.

Я просто пытаюсь выполнить простой поиск.

.html

    <ion-searchbar (ionInput)="getClinicName($event)"></ion-searchbar>
    <br> 
    <ion-list *ngIf="listAllClinic">
      <button ion-item *ngFor="let data of listAllClinic" (click)=" openClinic(data.clinic_regno,data.clinic_name,data.site,data.clinic_address)" >
        {{ data.clinic_name }} <ion-icon name="ios-arrow-forward-outline" item-right></ion-icon>
      </button>  

.ts


ionViewWillEnter()
{
  this.authService.getClinicList()
  .then(data => {
    this.clinic1 = data;
    this.listAllClinic = this.clinic1.clinic_list;
    console.log(this.listAllClinic);
  });

}

  //SEARCH BY CLINIC
 getClinicName(ev: any) 
 {  // Reset items back to all of the items
    this.ionViewDidLoad();
    // set val to the value of the ev target
    var serVal = ev.target.value;
     // if the value is an empty string don't filter the items
    if (serVal && serVal.trim() != '') {
      this.listAllClinic = this.listAllClinic.filter((data) => {
        return (data.clinic_name.toLowerCase().indexOf(serVal.toLowerCase()) > -1);
      })
  }

authservice.ts

  getClinicList(){
    return new Promise(resolve => {
      this.http.get(apiUrl + 'listAllClinic').subscribe(data => {
        resolve(data.json());
      }, err => {
        console.log(err);
      });
    });
  }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...