Currently, it seems that this task is not achievable without directly modifying the DOM. As others have said, invokeElementMethod () is deprecated. However, you will find problems using selectRootElement, as this is not its target, and you will lose children inside your DIV. Here is a link to a SO question that explains selectRootElement in more detail (since angular docs are awful):
Renderer multiple selectRootElement Issue (with plnkr provided)
At the moment, it seems that the only way to easily achieve your goal is to use a template reference variable, a child of the view, and your viewChild.nativeElement.focus () (although this practice is also not recommended)
There is also a workaround using FocusService found in this GitHub issue: https://github.com/angular/angular/issues/15674
In this release, Tytskyi mentions that you can implement FocusService and provide various focus () implementations based on AppModuleBrowser and AppModuleServer. I'm not sure about the details of how this works, but this may be the only way to achieve this without using nativeElement at this time.
source share