For some reason my @ViewChild in my Angular 5 App does not work. I have defined it like this in my component:
case-detail.component.html:
<div class="inner-tab-content" #innerTabContent>
<!-- // more content here -->
</div>
I have implemented @ViewChild
in my controller (above the constructor) like this:
case-detail.component.ts
@ViewChild('innerTabContent') tabContentElement: ElementRef;
And I want to access it here in the component: case-detail.component.ts
ngAfterViewInit() {
console.log("scroll top: " + this.tabContentElement.nativeElement);
}
I've implemented the AfterViewInit
interface. ngAfterViewInit() is called correctly. However, this.tabContentElement
is always undefined
.
Any help is greatly appreciated :)