It is possible to set focus using setFocus method from nativeEloment.
But how about remove focus?
How could I remove the cursor from and unselect an input from a template in a Angular 2+/Ionic 3 app?
I need to remove the focus because the mobile keyboard keeps open while a input has focus.
Edit: The input is a ion-input of Ionic2+.
1) Add a template variable reference to your input in your component's template:
2) Add
ElementRef
andViewChild
to your component's imports:3) Add
@ViewChild
variable and relevant methods to your component:You can trigger
setFocus()
orremoveFocus()
in a number of ways. Here's an example: