Search code examples
carouselngx-bootstrap

ngx-boostrap carousel add slides with button


I made a carousel with nxg-bootstrap, but when i try to add some slides dynamically with a button, i get indexerrors on click the arrows.

I have tryed to replace the complete slides array but same problem.

Stackblitz example: https://stackblitz.com/edit/ngx-bootstrap-itemperslide-carousel-example-jc4a8r?file=app/basic.html

have anyone a idea how can i fix this?


Solution

  • It seems dynamic ngx-carousel only works with one item per Slide. So if you remove the itemsPerSlide property and add the activeSliveIndex that would work.

    I've forked your Stackblitz and make those changes to show you how it works:

    https://stackblitz.com/edit/ngx-bootstrap-itemperslide-carousel-example-oxm55r

    I hope that helps!