Ionic ion-slides autoplay not working

i am adding the autoplay to the ion slides like this.

<ion-content>
  <div class="images_container">
  <ion-slides autoplay="400" loop="true" speed="3000">
    <ion-slide *ngFor="let image of images">
    <img src={{image.img_name}} >
    </ion-slide>
  </ion-slides>
  </div>
</ion-content>

and got error…

TypeError: Cannot read property ‘hasAttribute’ of undefined
at autoplay (http://localhost:8101/build/main.js:41401:20)
at startAutoplay (http://localhost:8101/build/main.js:41444:5)
at initSwiper (http://localhost:8101/build/main.js:41390:9)
at Slides._initSlides (http://localhost:8101/build/main.js:52527:102)
at http://localhost:8101/build/main.js:52244:23
at SafeSubscriber.schedulerFn [as _next] (http://localhost:8101/build/main.js:4213:36)
at SafeSubscriber.__tryOrUnsub (http://localhost:8101/build/main.js:39289:16)
at SafeSubscriber.next (http://localhost:8101/build/main.js:39238:22)
at Subscriber._next (http://localhost:8101/build/main.js:39180:26)
at Subscriber.next (http://localhost:8101/build/main.js:39144:18)
at EventEmitter.Subject.next (http://localhost:8101/build/main.js:56442:25)
at EventEmitter.emit (http://localhost:8101/build/main.js:4187:76)
at Array. (http://localhost:8101/build/main.js:39027:46)
at MDTransition.Animation._fireBeforeReadFunc (http://localhost:8101/build/main.js:23436:33)
at MDTransition.Animation._beforeAnimation (http://localhost:8101/build/main.js:23363:14)

Ionic Framework: 3.0.1
Ionic App Scripts: 1.3.0
Angular Core: 4.0.0
Angular Compiler CLI: 4.0.0
Node: 6.9.2
OS Platform: macOS Sierra
Navigator Platform: MacIntel

thanks!

Did you fix this issue?

i am also facing same problem without autoplay its working fine.

1 Like

may be this will help ( it helps mine )

2 Likes

Use this in Ionic 5

   <ion-slides pager #mySlider class="slides" (ionSlidesDidLoad)="slidesDidLoad(mySlider)">
    <ion-slide *ngFor="let number of [1,2,3,4]">
    <img src="./assets/images/{{number}}.jpg" />
  </ion-slide>
  </ion-slides>


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