1

I have to autoplay the ion-slides in ionic-4 . But it is not working . I have tried please refer my code below

i have used autoplay="true" but still not working.

.html

<div>  
        <ion-slides [options]="sliderConfig">
          <ion-slide *ngFor="let cat of latestProducts">
            <div class="slide-content">
              <ion-card>
                <ion-card-header>
                  <ion-card-title class="card-title">
                      {{cat.post_title}}
                  </ion-card-title>
                  <ion-card-content>
                    <img class="image-wrap" src="{{cat.post_image_url}}">
                  </ion-card-content>
                </ion-card-header>
              </ion-card>
            </div>
          </ion-slide>
        </ion-slides>
      </div>

.ts

sliderConfig = {
    initialSlide: 0,
    speed: 400,
     slidesPerView: 1.45,
     autoplay: true,
  };

  @ViewChild(IonSlides) slides: IonSlides;
slidesDidLoad(slides: IonSlides) {
    slides.startAutoplay();
  }

I want to autoplay the slides.

user9483522
  • 304
  • 5
  • 20

1 Answers1

0

Can you try this?

   <ion-slides #mySlider (ionSlidesDidLoad)="slidesDidLoad(mySlider)">
      ...
    </ion-slides>


    slidesDidLoad(slides: Slides) {
      slides.startAutoplay();
    }

Then you can see https://github.com/ionic-team/ionic/issues/15046