Как использовать автозаполнение в строке поиска на Ionic 4?

Это регулярное выражение должно соответствовать тому, что вы хотите:

(start((?!start).)*?end)

Используйте метод re.findall и однострочный модификатор re.S, чтобы получить все вхождения в многострочной строке:

re.findall('(start((?!start).)*?end)', text, re.S)

Смотрите здесь .

0
задан M. Mariscal 5 March 2019 в 08:34
поделиться

1 ответ

В вашем HTML

 <ion-searchbar type="text" debounce="500" (ionInput)="getItems($event)"></ion-searchbar>
<ion-list *ngIf="isItemAvailable">
  <ion-item *ngFor="let item of items">
    {{ item }}
  </ion-item>
</ion-list>

в вашем файле

this.isItemAvailable = false; // initialize the items with false

initializeItems(){ 
    this.items = ["Ram","gopi", "dravid"]; 
}

getItems(ev: any) {
    // Reset items back to all of the items
    this.initializeItems();

    // set val to the value of the searchbar
    const val = ev.target.value;

    // if the value is an empty string don't filter the items
    if (val && val.trim() != '') {
      this.isItemAvailable = true;
      this.items = this.items.filter((item) => {
        return (item.toLowerCase().indexOf(val.toLowerCase()) > -1);
      })
    }
  }
0
ответ дан Mohan Gopi 5 March 2019 в 08:34
поделиться
Другие вопросы по тегам:

Похожие вопросы: