Complete the code to import the Angular CDK virtual scrolling module.
import { [1] } from '@angular/cdk/scrolling';
The correct module to import for virtual scrolling is ScrollingModule from Angular CDK.
Complete the template code to enable virtual scrolling with a fixed item size.
<cdk-virtual-scroll-viewport itemSize=[1]> <div *cdkVirtualFor="let item of items">{{item}}</div> </cdk-virtual-scroll-viewport>
The itemSize input expects a number representing the pixel height of each item, so 50 is correct.
Fix the error in the component code to correctly provide the list for virtual scrolling.
items = Array.from({length: 1000}, (_, i) => [1]);
The virtual scroll list should be an array of strings like 'item 0', 'item 1', etc. So 'item ' + i is correct.
Fill both blanks to set the viewport height and enable virtual scrolling in the template.
<cdk-virtual-scroll-viewport [1]="200px" itemSize=[2]> <div *cdkVirtualFor="let item of items">{{item}}</div> </cdk-virtual-scroll-viewport>
The viewport height is set using the style.height="200px" attribute, and itemSize=50 provides the fixed pixel height for each item.
Fill all three blanks to create a virtual scroll viewport with a fixed height, item size, and track the rendered range.
<cdk-virtual-scroll-viewport [1]="300px" itemSize=[2] (scrolledIndexChange)="[3] = $event"> <div *cdkVirtualFor="let item of items">{{item}}</div> </cdk-virtual-scroll-viewport>
Use style.height to set viewport height, 50 as item size in pixels, and startIndex to track the scrolled index.