question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Ionic v4 with angular| Slides getActiveIndex, isBeginning and isEnd methods return not proper value

See original GitHub issue

Bug Report

Ionic Info Run ionic info from a terminal/cmd prompt and paste the output below.

Ionic:

   ionic (Ionic CLI)          : 4.0.1 (/Users/bilal/.config/yarn/global/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.0
   @angular-devkit/core       : 0.7.0-rc.3
   @angular-devkit/schematics : 0.7.0-rc.3
   @angular/cli               : 6.0.8
   @ionic/ng-toolkit          : 1.0.0
   @ionic/schematics-angular  : 1.0.1

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : none

System:

   Android SDK Tools : 26.1.1
   ios-deploy        : 1.9.2
   ios-sim           : 6.1.2
   NodeJS            : v8.9.4 (/Users/bilal/.nvm/versions/node/v8.9.4/bin/node)
   npm               : 6.2.0
   OS                : macOS High Sierra
   Xcode             : Xcode 9.4.1 Build version 9F2000

Environment:

   ANDROID_HOME : /Users/bilal/Library/Android/sdk

Describe the Bug Slides getActiveIndex,isBeginning and isEnd methods return not proper value. They return following: ZoneAwarePromise {__zone_symbol__state: null, __zone_symbol__value: Array[0]}

Steps to Reproduce Steps to reproduce the behavior:

  1. Go to stackblitz example.
  2. Click on Info button.
  3. Check console.

Related Code https://stackblitz.com/edit/ion-slides-info

Expected Behavior getActiveIndex method should return index value and isBeginning and isEnd method should return boolean value.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
adamlacombecommented, Aug 5, 2018

Try this: https://stackblitz.com/edit/ion-slides-info-bzpu9s

app.component.html

<ion-slides #slides [pager]="true">

app.component.ts

@ViewChild('slides') slides;
const index = this.slides.nativeElement.getActiveIndex();

I’m not very familiar with Ionic Angular (or Angular in general), but it looks like you’ll have to use the nativeElement property to be able to fire off methods in any Ionic element.

1reaction
oremikecommented, Aug 5, 2018

when viewing the app using ionic serve, the promise response works nicely (coded while in ionic serve). Then if run ionic build I get a compile error with error TS2339: Property ‘then’ does not exist on type ‘number’. I then have to convert to a normal assignment to either run ionic serve, or ionic build so it does not fail on build. slightly unusual behaviour. This was on 4.0.2. I’ve just upgraded to 4.06 so will retest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IONIC 4 : getActiveIndex() is not working in ion-slides
Using IONIC 4 ion-slides, I am trying to get currently clicked silde index using getActiveIndex() as below which it is not working.
Read more >
IONIC 4 : getActiveIndex() is not working in ion-slides
Note that although it seems to work, I suspect that because the value is changes inside promise, it will only return the correct...
Read more >
Getting Getactiveindex Wrong In Ionic Slider - ADocLib
... this behaviour. should contain the slide container, [Ionic v4 with angular| Slides getActiveIndex, isBeginning and isEnd methods return not proper.
Read more >
Building a slideshow with Ionic Slides API - Mastering Ionic
In this coding tutorial we will walk through using the Ionic Slides API to create stunning slideshow components for our mobile applications ...
Read more >
how to let the first slide appear after button click also in antd ...
length - 1; return ( <div className="carousel-button-group" style={{ position: "absolute" }}> <button onClick={() => currentSlide === 0 ? goToSlide( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found