1.first you need add #input into the html label
2.add click event like (click)="showSearchBar(input)"
3.use input.setFocus();
Bonus: Making the keyboard appear on a device
Now setting focus to an input and getting the keyboard to appear on a device can be quite a pain. But it’s rather simple to get it to work. Just add the following to your cordova’s config.xml
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
Now when you call focusInput
, the keyboard will display as well.
*ngIf can controll ion-searchbar hidden and show more convenience