Hi all,
I have a bit of a conundrum…
I have setup Slides within Slides and need to call the inner slides getActiveIndex(). The number of slides is dynamic. I cannot set a dynamic template variable to use @ViewChild, as this is not allowed.
Any suggestions on how I can access the index of the inner Slides component?
<ion-slides class="suit-slider" #SuitSlider (ionDidChange)="onSuitChanged()" [options]="suitSliderOptions">
<ion-slide *ngFor="let suit of deck; let i = index;">
<ion-slides #CardSlider (ionDidChange)="onCardChanged()" [options]="cardSliderOptions">
<ion-slide>
<div class="lrn-card" [style.borderColor]="suit.colour">
<div class="lrn-card__body" [innerHTML]="suit.body"></div>
</div>
</ion-slide>
<ion-slide *ngFor="let card of suit.cards">
<div class="lrn-card" [style.borderColor]="suit.colour">
<h2 class="lrn-card__title">{{card.title}}</h2>
<div class="lrn-card__body" [innerHTML]="card.body"></div>
</div>
</ion-slide>
</ion-slides>
</ion-slide>
</ion-slides>
I then access this via:
@ViewChild(‘CardSlider’) cardSlider: Slides;
However, in my example #CardSlider is not unique and is shared by all inner Slides. This means only the first CardSlider’s values are returned in ionDidChange().
I was thinking that I would end up with as follows:
- Slide 0
CardSlider0 - Slide 1
CardSlider1 - Slide 2
CardSlider3
Anyone know of a way to get the unique CardSlider value for each slide? reading up on Ang2 docs, it looks as though @ViewChild is a static attribute and cannot be set dynamically.
It seems like it should be simple…
Thanks