I have a regular input ( not an ionic input ) inside of a modal. I want to autofocus it after the modal slides up, but the code I thought would work does not, the input does not focus and the keyboard does not show up.
HTML
<input #test id="test"
(touchstart)="focusInput()"
(keypress)="enterPress($event)"
maxlength="20"
class="pure-input"
type="text"
placeholder="Test...">
Component:
I have tried this in a setTimeout or just by itself
ngOnInit() {
let ele = document.getElementById('test');
ele.focus();
}
Also tried calling this
public focusInput() {
this.testInput.nativeElement.focus();
}
Neither works on the input