How to complete ion-search bar?

#1

Hi,
I am able to fetch data from api and it is properly displaying in list item, when I search from serachbar.
But I want to fill searchbar when I clicked a particular displayed ion item list.hidf
How do I get value of clicked ion-item list.
Is this possible in Ionic?
Here is my code:

<ion-searchbar 	[(ngModel)]="searchText" (ionInput)="search($event)" #id1 placeholder="">
  </ion-searchbar>
  <ion-list>
		<ion-item *ngFor="let stations of stationlist" >
			{{stations.v}}
		</ion-item>
  </ion-list>
#2

add a click attribute to your ion-item, (click)="searchText = stations.v".

You are setting your searchText which is bound and shown in your ion-searchbar as the the station name string.

1 Like
#3

I got your point. Thanks!
One last help, how can I access searchbar input properties in ts file. As shown in this doc


Say how to set placeholder from my ts file.
I tried accessing this way
this.searchText.placeholder=station.v but unfortunately this do not worked.