Auto-focus to ion-input Ionic v4

I am doing the migration of an ionic v3 app to ionic v4. I have encountered the problem that when doing the auto-focus on an ion-input the way to do it in ionic v3 does not work, I tried to create a directive to perform the auto-focus, but it has not helped me.

Have you encountered the same problem?


Ionic v3 auto-focus code:
.ts file:

import { ViewChild } from '@angular/core';

  selector: 'page-inventario',
  templateUrl: 'inventario.html'

export class InventarioPage{
  @ViewChild('inputInventarioCB') CBProductoInventario;
ionViewDidEnter() {

  focusInput(input) {
    this.timer = setTimeout(() => {


.html file:

<ion-input #inputInventarioCB type="text" placeholder="Código de barras" required [(ngModel)]="producto.codigoBarras" name="codigoBarras" (keypress)="controlTeclaIntro($event, codigoBarras)"</ion-input>

I think it isn’t there yet, but, how lucky you are, the very last commit in the Ionic project added by @manucorporat is the feature you are looking for

You should be good in next beta

1 Like

Thanks, I’ll take a look.