rintoj / ngx-virtual-scroller

Virtual Scroll displays a virtual, "infinite" list.
https://rintoj.github.io/ngx-virtual-scroller
MIT License
977 stars 294 forks source link

How can I use it with dynamic components? #179

Closed vitstr closed 6 years ago

vitstr commented 6 years ago

Hello, @rintoj How can I use the angular2-virtual-scroll with dynamic components? Could you provide an example of it?

lucasbasquerotto commented 6 years ago

@vitstr I made it work using the childHeight property (I don't know if your case is the same though):

<virtual-scroll [items]="items"
    [childWidth]="80"
    [childHeight]="30"
    (update)="viewPortItems = $event">

    <dynamic-item *ngFor="let item of viewPortItems" [item]="item">
    </dynamic-item>

</virtual-scroll>

My dynamic item has an anchor and create a component dynamically based on the class reference, using ViewContainerRef and ComponentFactoryResolver.

speige commented 6 years ago

@vitstr did lucasbasquerotto solve your issue? Closing for now. Please re-open if needed.