htmlangularangular-materialangular-cdkangular-cdk-virtual-scroll

CDK virtual scroll has no doms


I'm using CDK virtual scroll to improve the performance of a dropdown which will have huge data. I have followed all the steps as per the documentation. But when I open the dropdown I don't see any dom with in cdk-virtual-scroll-viewport component.

Here is the code from HTML.

<cdk-virtual-scroll-viewport itemSize="500" class="example-viewport">
            <div *cdkVirtualFor="let item of items" class="example-item">{{item.name}}</div>
        </cdk-virtual-scroll-viewport>

If I move the div outside the cdk virtual scroll and replace it with ngFor it works fine. Any idea what could be the issue?

enter image description here


Solution

  • The problem was that the scrolling module was not imported in the correct module file. It didn't give any error but was giving just a warning.