How to do auto-complete in ionic 2 (search-bar)

后端 未结 1 1388
夕颜
夕颜 2021-02-08 03:37

I am trying to do an auto complete in my search bar what i have done so far is.

I have an array with some strings. and then i am trying to list in my items it i am able

相关标签:
1条回答
  • 2021-02-08 04:08

    In order to achieve that, you just need to add a small thing to your code. Please take a look at this plunker.

    Like you can see there, with the showList variable we can show the results only after the user has searched something.

      <ion-list *ngIf="showList">
        <ion-item *ngFor="let item of items">
          {{ item }}
        </ion-item>
      </ion-list>
    

    We first set that variable to false in the constructor and then we set it to true inside the getItems(...) method.

    0 讨论(0)
提交回复
热议问题