Reputation: 6002
In component.css
you can access <component>
tag with :host
selector.
Is there a direct way to access it in component.ts
file?
I am aware of using ViewChild
and parentElement
, is there a more direct way of getting host DOM element?
Upvotes: 1
Views: 43
Reputation: 657248
You can inject it
class MyComponent {
constructor(private elRef:ElementRef) {}
ngAfterViewInit() {
this.elRef.nativeElement...
}
}
Upvotes: 2