3

I have developed angular4 based wizard, in every step I have form, switching between steps I wanted to have focus on first text-field, I'm able to get focus on first step with html attribute autofocus but only when page is loading, when I'm switching between steps not able to get focus.

Tried below examples but unfortunately no success,

Is there an Angular2 way to focus on an input field?

Created a example on plunker

ysiddiqui
  • 31
  • 1
  • Could you add the content of your research, some code for instance ? That would help others – rak007 Apr 09 '18 at 14:54

1 Answers1

0

I've successfully used the method described in your link above (Is there an Angular2 way to focus on an input field?), but I had to put the call to focus() in a setTimeout():

setTimeout(() => {
   (<HTMLInputElement> this.myInputField.nativeElement).focus();
}, 250);
kshetline
  • 12,547
  • 4
  • 37
  • 73