How can I always have focus on input field?


#1

So I have only one input field in my screen and want it to be always focused, so that keypad is up. So this is my approach at the moment.

HTML- Code:

<ion-input #input type="number" (blur)="getFocusBack"></ion-input> 

Component Code

@ViewChild('input') myInput ;
ionViewDidLoad() {
     setTimeout(() => {
        this.myInput.setFocus();
     },0);
}
getFocusBack(){
    setTimeout(() => {
        this.myInput.setFocus();
     },0);
}

Is there any good/other way of doing this?