Yes but I have template with div with ngFor. I did same in my example and it is not working.
On Tuesday, September 17, 2019, Sander Elias <[email protected]> wrote: > Hi Dev, > > > Setting the focus from withing angular is the same as for native js. > > @ViewChild("someTemplateVar") someTemplateVar: ElementRef; > someMethod(): void { > if (this.someTemplateVar.nativeElement) { > this.someTemplateVar.nativeElement.focus(); > } > } > > Wrapping inside the if makes sure you will not run into problems with SSR. > > Regards > Sander > > > > -- > You received this message because you are subscribed to the Google Groups > "Angular and AngularJS discussion" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/angular/7b75229a-34b7-44bf-b1b0-2f3d85e277dd%40googlegroups.com > <https://groups.google.com/d/msgid/angular/7b75229a-34b7-44bf-b1b0-2f3d85e277dd%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Sent from my mi note 4 phone. -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/CAKVZMjCu9x_wQ%2BPjunxB4TKhivB9234eeo%3DQH9F%2B5cU%2BtFWG8w%40mail.gmail.com.
