D
D
DTX2016-04-04 23:04:52
JavaScript
DTX, 2016-04-04 23:04:52

Angular2. How to set focus on input on click?

I tried to set a variable for the input field:
<input #inp>
but nothing good came of it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2016-04-05
@DirecTwiX

html code

<input #inp>
<button (click)="focus($event, inp)">focus</button>

Component add a function
focus(e, el) {
    el.focus();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question