I have a view with an input <ion-input #codigobarras></ion-input>
How can I auto focus on this input?
@ViewChild('codigobarras') input_codigobarras: Input;
...
ionViewDidEnter() {
this.input_codigobarras.focus(); // didn't work = temp2.focus is not a function
this.input_codigobarras.focus.emit(); // didn't work = do nothing, just returns undefined
this.input_codigobarras.getElementRef().nativeElement.focus() // didn't work = do nothing, just returns undefined
this.input_codigobarras.setFocus(); // didn't work = do nothing, just returns undefined
}
<ion-input [autofocus]></ion-input> <!-- Didn't work -->
This should work
<ion-input autofocus="true"></ion-input>