How to focus on ion input on page enter ? Ionic 3


Good morning
i had an ion input inside my page i want to set focus on it when the page enter ( i tried setFocus() on the ionViewDidEnter() but it didn’t work, knowing that it works perfect if i set a button which trigger the function setFocus on click event)


any answer friends ???

// in HTML file
<ion-input #si placeholder="Search Patient" [(ngModel)]="searchPatientString"></ion-input>

// in TS file
import { ViewChild } from '@angular/core'; 
import { Input } from 'ionic-angular';

@ViewChild('si') searchInput: Input;

-- in constructor


i can’t put this.searchInput.setFocus(); in the constuctor cuz when the constructor start it didn’t know yet the variable searchInput (i think)


try to put that in ionViewDidLoad();