1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How to set focus on an input that works on IOS supporting devices?

Discussão em 'Angular' iniciado por Vega, Novembro 8, 2024 às 06:22.

  1. Vega

    Vega Guest

    My aim is to set focus on an input via the button click method.

    I used a template variable, but doing it via component code seems to give the same result.

    This works as expected on all devices where I tested (MacBook and some mobile devices) whatever the browser is, i.e. Safari, Chrome, Firefox, however it doesn't work on iOS supporting devices. Nothing happens.
    Here is the snippet of the code which is supposed to set the focus to an input on a button click.

    Important: It should be run on an iPhone or an iPad.

    HTML

    <input #input type="text">

    <button type="button" (click)="input.focus()">Click to set focus on the input</button>


    Here is a small demo for the issue.

    Continue reading...

Compartilhe esta Página