0

Need to know is it possible to use this new feature @angular/cdk/scrolling in a specific accordion like ng-bootstrap's (in mat-accordion it is https://stackblitz.com/edit/virtual-scroll-expansion-panels?file=app%2Fapp.component.ts)

https://stackblitz.com/edit/angular-ahzm1v?file=app%2Faccordion-basic.ts

msanford
  • 11,803
  • 11
  • 66
  • 93
Den Kerny
  • 562
  • 10
  • 18

1 Answers1

0

Yes, possible a component consisting of the virtual scroll will reside inside the accordion component.

check the demo here

accordian.component.html:

<ngb-accordion #acc="ngbAccordion" >
    <ngb-panel [title]="num" *ngFor="let num of numbers">
        <ng-template ngbPanelContent>
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute,
            non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua
            put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore
            wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings
            <cdk-virtual-scroll> Loading..... </cdk-virtual-scroll>
            occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore
            sustainable VHS.
        </ng-template>
    </ngb-panel>
</ngb-accordion>

EDIT: The stackblitz code above is still relevant. The following CSS makes the accordian inside a virtual scroll.

  ngb-accordion {
    height: 400px;
    display: block;
    overflow-y: scroll; }
Akber Iqbal
  • 14,487
  • 12
  • 48
  • 70