When I retrieve image slider data from a provider's REST API, the autoplay feature works perfectly. However, after manually sliding through the images, the autoplay function stops working. When I try to use ionViewDidEnter(), it triggers an error...
In my .ts file, the code is as follows:
import {Slides } from 'ionic-angular';
.
.
.
export class DemoPage {
.
.
.
@ViewChild(Slides) slides: Slides;
.
.
.
allslider: any;
.
.
constructor(public navCtrl: NavController, public navParams: NavParams,public popoverCtrl: PopoverController,public demoapiService: DemoApiProvider)
{
this.imgSlider();
}
imgSlider() {
this.demoapiService.getImgSlider()
.then(myslide => {
this.allslider= myslide ;
});
}
ionViewDidEnter()
{
// this.slides.autoplayDisableOnInteraction = false;
// when used above statement then error is generated
}
My .html file looks like this:
<ion-slides class="slide-css" #slides *ngIf="allslider && allslider.length" [autoplay]="2000" [speed]="500" [loop]="true" pager>
<ion-slide *ngFor="let slide of allslider ">
<img src="http://localhost:8000/{{slide.img}}" />
</ion-slide>
</ion-slides>
For more information, check out ionic 3 image slider stops autoplay after manual sliding