Sunday, 13 October 2019

asNavFor not working ngx-slick-carousel in Angular 8

I am working on a project made in Angular 8 & want to use a third-party library such as ngx-slick-carousel and everything is working fine but I have thumbnail carousel, where an option like asNavFor, see the below attributes

imagesSlider = {
  speed:300,
  slidesToShow:1,
  slidesToScroll:1,
  cssEase:'linear',
  fade:true,
  autoplay: true,
  draggable:true,
  prevArrow:'.client-feedback .prev-arrow',
  nextArrow:'.client-feedback .next-arrow',
  asNavFor:".client-thumbnails",
};
thumbnailsSlider = {
  speed:300,
  slidesToShow:5,
  slidesToScroll:1,
  cssEase:'linear',
  autoplay: true,
  centerMode:true,
  draggable:false,
  focusOnSelect:true,
  asNavFor:".feedback-slides .client-feedback",
  prevArrow:'.client-thumbnails .prev-arrow',
  nextArrow:'.client-thumbnails .next-arrow',
};

and the HTML looks like

<div class="feedback-slides">
   <div class="client-feedback">
        <ngx-slick-carousel 
            class="carousel" 
            #slickModal="slick-carousel" 
            [config]="imagesSlider">
            <div ngxSlickItem *ngFor="let slide of slides" class="slide">
                    <img src="" alt="" width="100%">
            </div>
        </ngx-slick-carousel>
    </div>
</div>

<div class="client-thumbnails">
     <ngx-slick-carousel 
        class="carousel" 
        #slickModal="slick-carousel" 
        [config]="thumbnailsSlider ">
        <div ngxSlickItem *ngFor="let slide of slides" class="slide">
                <img src="" alt="" width="100%">
        </div>
    </ngx-slick-carousel>
</div>

as above codes not working & showing an error in the console like

Uncaught TypeError: Cannot read property 'getSlick' of undefined

If I remove the option asNavFor error will disappear but thumb click doesn't work anymore.

What can I do now?

Thanks



from asNavFor not working ngx-slick-carousel in Angular 8

No comments:

Post a Comment