我想做这样的事情:
<cdk-virtual-scroll-viewport [itemSize]="25">
<svg>
<g *cdkVirtualFor="let item of items">...</g>
</svg>
<div *cdkVirtualFor="let item of items">...</div>
</cdk-virtual-scroll-viewport>
同时使g
和div
元素同时滚动(它们都具有相同的高度)。这可能吗?完全按照我在此处概述的操作会导致错误:Error: CdkVirtualScrollViewport is already attached.
答案 0 :(得分:0)
这是我如何通过虚拟滚动获得2个列表的方法: 我合并了列表,添加了类型,按类型对列表进行排序,并在更改类型时中断了:
ts file:
didGroupChange(jobNow:JobsResponse, jobPrev:JobsResponse){
return jobNow.type!==jobPrev?.type;
}
HTML:
<cdk-virtual-scroll-viewport [itemSize]="20" class="scroll-panel-jobs">
<dl>
<ng-container *cdkVirtualFor="let job of country?.jobsList; let index = index;">
<dt *ngIf="didGroupChange(job,country?.jobsList[index-1])" class="line row h15 title-job">{{job.type}}</dt>
<dd class="line row h16">{{job.title}} </dd>
</ng-container>
</dl>
</cdk-virtual-scroll-viewport>