Hi David,

Yeah, `autofocus` does not work on dynamic content. 
In such a case, you should use `@ViewChild`. I use this dirty undocumented 
trick:
@ViewChild('selector', { read: ElementRef }) private set _doFocus(ref: 
ElementRef) {
if (ref.nativeElement) {ref.nativeElement.focus()}
}

If you want to stay away from undocumented things, do the `@ViewChid` as 
you are used to, but do this:
ngAfterContentInit(): void {
if (viewChildPropName.nativeElement) {
setTimeout(() => viewChildPropName.nativeElement.focus(),0)
}
}

The setTimout pushed the action to the next frame and will make the thing 
work.

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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to