Estoy usando CDK VIRTUAL SCROLL en una tabla que carga un servicio (API) que me devuelve una lista, con esta lista puedo quitar o devolver sus columnas respectivamente así como sus elementos, pero cuando elimino todas las columnas de la tabla y solicitó regresar, ¡solo las columnas terminaron regresando normalmente pero sus artículos no!
puedes tener algo como
<table> <cdk-virtual-scroll-viewport #scroller itemSize="6" class="content"> <ng-container *cdkVirtualFor="let item of items; let i = index"> <thead *ngIf="!i"> <tr> <td>Prop1</td> <td>Prop2</td> </tr> </thead> <tr> <td style="min-width:10rem"> {{ item.prop1 }} </td> <td style="min-width:10rem">{{ item.prop1 }}</td> </tr> </ng-container> </cdk-virtual-scroll-viewport> </table>Con un cdkscroll "típico"
ngOnInit() { this.fetchMore(); this.scroller.elementScrolled().pipe( map(() => this.scroller.measureScrollOffset('bottom')), pairwise(), filter(([y1, y2]) => (y2 < y1 && y2 < 140)), throttleTime(200) ).subscribe(() => { this.ngZone.run(() => { this.fetchMore(); }) } ); } fetchMore(): void { const newItems="......." this.items=[...this.items,...newItems] }ver un pequeño stackblitz