0

I implement a small single page in Angular. After opening a second component as a dialog window i need to focus my first input field ( & cursor should at position 1).

Current Situation: i have focus but the cursor isnt inside the field

  @ViewChild('gericht') gericht: ElementRef<MatInput>;
  public putInFocus() { this.gericht.nativeElement.focus(); }

Browser like chrome or firefox don't have a problem with the method .focus()

Have someone any idea? Thanks.

  • Is there any error in console in IE? Could you please provide a [minimal, reproducible sample](https://stackoverflow.com/help/minimal-reproducible-example) so that we can have a test and see how to help. With only the above codes, we can't reproduce and locate the issue. Besides, you could try the accepted answer of using `setTimeout` in [this thread](https://stackoverflow.com/questions/2600186/focus-doesnt-work-in-ie) to see if it works. – Yu Zhou Jan 20 '20 at 09:15
  • hi, thank you for u answer. I already tried this solution. – Frederik.Wagener Jan 21 '20 at 10:25
  • @YuZhou i have no error – Frederik.Wagener Jan 21 '20 at 11:22
  • Could you please give us a reproducible sample? With only the above code, we can't reproduce the issue. You could provide an online code sample using [stackblitz](https://stackblitz.com/) or any other online code editor. – Yu Zhou Jan 22 '20 at 02:29

0 Answers0