Ion Slides Throws "_activeIndex is undefined" Error


#1

This issue has only come up when I try to use the autoplay feature.

I have tried to include the option in the html:

<ion-slides #homeSlides 
*ngIf="slides" 
autoplay="5000"
autoplayDisableOnInteraction="false"
initialSlide=0 
pager="true"
loop="true"
effect="fade"
autoHeight="true" >
  <ion-slide *ngFor="let slide of slides" >
    <ion-card (click) = "openPage(slide.component)">
      <img id= "slide-img" [src]= "slide.img">
      <div class="card-title" text-wrap> {{slide.title}} </div>
      <div class="card-subtitle" text-wrap> {{slide.subtitle}} </div>
    </ion-card>
  </ion-slide>
</ion-slides>

Also have tried enabling it in my component:

@ViewChild('homeSlides') slider: Slides;

ionViewDidLoad() {
  this.slider.update();
  this.slider.autoplay = 5000;
  this.slider.startAutoplay();

}

With the second method the stacktrace is:

ERROR TypeError: s._activeIndex is undefined
Stack trace:
autoplay@http://localhost:8100/build/main.js:42425:26
startAutoplay@http://localhost:8100/build/main.js:42469:5
Slides.prototype.startAutoplay@http://localhost:8100/build/main.js:55099:9
HomePage.prototype.ionViewDidLoad@http://localhost:8100/build/main.js:45351:9
ViewController.prototype._lifecycle@http://localhost:8100/build/main.js:17317:13
ViewController.prototype._didLoad@http://localhost:8100/build/main.js:17190:9
NavControllerBase.prototype._didLoad@http://localhost:8100/build/main.js:44560:13
....

I have looked through the Slides and Swiper implementations on GitHub but I cannot find where _activeIndex (or activeIndex) gets a value other than null.

I know this is occurring on the autoplay() function at line 204 in the swiper.ts file.

Hopefully the source will help someone spot my mistake.

Not sure if this has anything to do with it, but when I try to use the [options] property and load in properties from an array I always get the error:

Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'ion-slides'.

Anyone know how to solve this problem? Thanks!


#2

What is your ionic info output?
Did you search the forum and Github issues for similar problems?


#3
$ ionic info

global packages:

  @ionic/cli-utils : 1.4.0
  Ionic CLI        : 3.4.0

local packages:

  @ionic/app-scripts              : 1.3.7
  @ionic/cli-plugin-ionic-angular : 1.3.1
  Ionic Framework                 : ionic-angular 3.4.0

System:

  Node       : v8.1.0
  OS         : OS X El Capitan
  Xcode      : Xcode 7.3.1 Build version 7D1014
  ios-deploy : 1.9.1
  ios-sim    : 6.0.0

Yes I have been looking in various places for an answer. Cannot find anything pertaining to my particular issue.


#4

Ok, then let us know how you run/build your app and where and how exactly you are testing.
Can you create a simple project to reproduce the issue and put it on Github?