I'm trying to listen to scroll event on an element of my template thanks to cdkScrollable.
Typescript:
@ViewChild(CdkScrollable, {static: false})
public scrollable: CdkScrollable;
...
public ngAfterViewInit() {
this.scrollable.subscribe(this.scrollDetected)
}
Template:
<pre
cdk-scrollable
#fareNotes
[innerHTML]="changeFareNotes">
</pre>
However, this.scrollable is always undefined.
If I try to define the ViewChild as follow, it exists, but only gets the ElementRef type (with only nativeElement property but not the scrollable() method).
@ViewChild('fareNotes', {static: false})
public fareNotes: CdkScrollable;
So:
Credits go to David Fontes and andreivictor for the helpfull comments.