When I mouse over certain elements, I use the following code to set focus:
<div #divTemplateVar (mouseover)="divTemplateVar.focus()"></div>
However, this method does not work for components:
<component #componentTemplateVar (mouseover)="componentTemplateVar.focus()"></component>
I am aware that I can use
viewChild('componentTemplateVar', { read: ElementRef })
to select the component in the template. But I have multiple components that need to automatically focus themselves on mouseover, and I do not want to manually write a view child for each one.
Is there a way to make component children auto-focus themselves on the mouseover event?