td-virtual-scroll-container
element calculates the items that fit in the viewport and only renders those, improving resource efficiency in long lists.
NOTE: every row has to have the same height, since there are some calculations assumed for the total scroll height.
Import the [CovalentVirtualScrollModule] in your NgModule:
import { CovalentVirtualScrollModule } from '@covalent/core/virtual-scroll'; @NgModule({ imports: [ CovalentVirtualScrollModule, ... ], ... }) export class MyModule {}
Example for HTML usage:
<td-virtual-scroll-container [style.height.px]="400" [data]="data" [trackBy]="trackByFn" (bottom)="fetchMoreData()"> <ng-template let-row="row" let-index="index" let-first="first" let-last="last" let-odd="odd" let-even="even" tdVirtualScrollRow> {{row}} </ng-template> </td-virtual-scroll-container>