I was getting an issue regarding auto focus in Ionic 4 and Angular 8 App
While I was opening the search modal in app, I wanted to auto focus on search box
I was getting an issue regarding auto focus in Ionic 4 and Angular 8 App
While I was opening the search modal in app, I wanted to auto focus on search box
For that I found the solution
I have added reference element on Input field
Ionic Code
<ion-input placeholder="Search for Products" #product_id></ion-input>
Search Modal Component Code
import { IonInput } from '@ionic/angular';
export class SearchModalComponent implements OnInit {
@ViewChild('product_id', {static:true}) product_id:IonInput;
ngAfterViewInit() {
setTimeout(() => {
this.product_id.setFocus();
},500);
}
}