ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.01k stars 13.51k forks source link

bug: (ion-slides) getActiveIndex() #20755

Closed sercatven closed 4 years ago

sercatven commented 4 years ago

Bug Report

Ionic version: [x] 5.x [x] Angular 9.x.x

Current behavior: When you open a new page with slides you only get the index of slide in the first opening. If you go back and access again, it does not recover the index.

In Angular 8 works fine.

ezgif com-video-to-gif

Steps to reproduce: Home --> Slides --> getActiveIndex() OK --> Home --> Slides --> getActiveIndex() not work

Related code:

https://github.com/sercatven/slides-ionic5

slides.html
  <ion-slides pager="true" (ionSlideDidChange)="change($event)">
    <ion-slide>
      <h1>Slide 1</h1>
    </ion-slide>
    <ion-slide>
      <h1>Slide 2</h1>
    </ion-slide>
    <ion-slide>
      <h1>Slide 3</h1>
    </ion-slide>
  </ion-slides>

slides.ts
  @ViewChild(IonSlides) slides: IonSlides;

  change(event){
    this.slides.getActiveIndex().then(index => {     
      console.log("Current index: " + index);
    });
  }

Other information:

Ionic info:

Ionic:

   Ionic CLI                     : 6.2.1 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.0.5
   @angular-devkit/build-angular : 0.900.6
   @angular-devkit/schematics    : 8.3.25
   @angular/cli                  : 9.0.6
   @ionic/angular-toolkit        : 2.2.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 4 other plugins)

Utility:

   cordova-res (update available: 0.10.0) : 0.3.0
   native-run (update available: 0.3.0)   : 0.2.9

System:

   ios-deploy : 1.9.4
   NodeJS     : v10.14.2 (/usr/local/bin/node)
   npm        : 6.14.2
   OS         : macOS Catalina
   Xcode      : Xcode 11.3.1 Build version 11C504
liamdebeasi commented 4 years ago

Thanks for the issue. I am going to close this as a duplicate of https://github.com/ionic-team/ionic/issues/20356.

ghost commented 4 years ago

I need a solution i am having the same issue please provide!

liamdebeasi commented 4 years ago

@SoufMobAr This has been fixed in Ionic Framework v5.0.7.

ionitron-bot[bot] commented 4 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.