Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49115

ViewChild with IonSlides doesn't work as expected

$
0
0

Hello,
I have a strange issue with ViewChild behaviour.
As you can see, i have a “basic” html

<ion-slides pager="true" #slides>
    <ion-slide>
        <ion-button expand="block" (click)="nextStep()">Next</ion-button>
    </ion-slide>

In ts file, im trying to access like that

  @ViewChild('slides') slides: IonSlides;

nextStep() {
    console.log('ionSLide', this.slides);
  }

And when i check the value in log, i always have “ElementRef” and not the componentInstance.
(I tried with static true/false, no differences) and with the read: IonSlides my variable is undefined.

I use ViewChild with angular since 3 years and i never had an issue like that, what is wrong ?

I’m using Ionic 5 and angular 10 or 11 (same issue).

Thanks guys !

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>