I am facing an issue where the
<cdk-virtual-scroll-viewport>
starts from the bottom, but I am unable to scroll up.
I suspect that this problem is related to the use of AfterViewChecked
. Even after trying AfterViewInit
, the issue persists.
@ViewChild(CdkVirtualScrollViewport, { static: false }) viewport: CdkVirtualScrollViewport;
ngAfterViewChecked() {
this.viewport.scrollTo({ bottom: 0 });
}
<cdk-virtual-scroll-viewport itemSize="70">
<div *cdkVirtualFor="let message of messages">
{{message}}
</div>
</cdk-virtual-scroll-viewport>
How can I enable scrolling upwards again? Or find a way to execute AfterViewChecked
only once?