In this article Create Advanced Component the author selects an element by first creating a directive:
@Directive({
selector: '.tooltip-container'
})
export class TooltipContainerDirective {}
And then using that directive to select the element containing the class .tooltip-container
like this:
@Component({
template: `
<div class="tooltip-container" [ngStyle]="{top: top}">
<ng-content></ng-content>
</div>
`,
styles: [...]
})
export class TooltipComponent implements OnInit {
top : string;
@ViewChild(TooltipContainerDirective, { read: ElementRef }) private tooltipContainer;
}
Does Angular have the ability to select the tooltipContainer
element by class name without using the directive?