I have different lists and I want to navigate to them with a segment. So that would be navigating about clicking the segment button. But I also want to navigate about sliding the list. Im doing that with slides. So logically when I click the button the slide should switch to the slide with the corresponding segment button and the active-index of the segment should update when sliding. But somehow these two mechanism are not interacting correctly. Because when im clicking the button the slide doesn't change, and when Im sliding the active index of the segment doesn't change. When I want to console log the two func. I notice that they are never called. Why is that? Here is my code:
html:
<ion-toolbar>
<ion-segment mode="md" [(ngModel)]="segment" (ionChange)="segmentChanged()">
<ion-segment-button value="0">
</ion-segment-button>
<ion-segment-button value="1">
</ion-segment-button>
<ion-segment-button value="2">
</ion-segment-button>
</ion-segment>
</ion-toolbar>
<div>
<ion-slides #slides (ionSlideDidChange)="slideChanged()" scrollbar="false">
<ion-slide>
<ion-list>
<ion-card>
</ion-card>
</ion-list>
</ion-slide>
<ion-slide>
<ion-list>
<ion-card>
</ion-card>
</ion-list>
</ion-slide>
<ion-slide>
<ion-list>
<ion-card>
</ion-card>
</ion-list>
</ion-slide>
</ion-slides>
</div>
ts:
@ViewChild('slides', { static: true }) slider: IonSlides;
...
async segmentChanged() {
await this.slider.slideTo(this.segment);
console.log(1)
}
async slideChanged() {
this.segment = await this.slider.getActiveIndex();
console.log(2)
}