Hi,
I am working on a ionic4 application that uses an array loop to generate content for ion-slides. Everything is okay till I try to use slideNext() or slideTo(index) to move to the next slide where it fails with no error and to get it to work I have to refresh the page with the slides.
Then when I try using swiping with the pager parameter set to true, the pager markers also do not appear until I refresh the page and when I do attempt to swipe, I can view the next slide but it slides back to the previous slide. Swiping also only works if I refresh the page. What could be the cause? I have tried downgrading from ionic5 to ionic4 with no success
The code I am using is:
<ion-slides #quizSlider>
<ion-slide *ngFor="let question of questions;let i = index">
<ion-list lines="none">
<ion-radio-group [(ngModel)]="singleanswer">
<ion-item *ngFor="let answer of question.answers">
<ion-label>{{answer}}</ion-label>
<ion-radio slot="start" value="{{answer}}">
</ion-radio>
</ion-item>
</ion-radio-group>
<div fxLayout="row" fxLayoutAlign="center" >
<ion-button color="primary" (click)="checkUserAnswers(i)">Check</ion-button>
</div>
</ion-list>
</ion-slide>
</ion-slides>
And the .ts is
import { IonSlides } from '@ionic/angular';
@ViewChild('quizSlider') quizSlider: IonSlides;
export class Quiz {
questions: Question[];
constructor() {}
checkUserAnswers(questionNo)
{
if(this.questions.length == questionNo + 1)
{
this.router.navigate(['complete']);
}
else
{
console.log('test');
//this.quizSlider.slideNext();
//this.quizSlider.lockSwipes(false);
this.quizSlider.slideNext();
//this.quizSlider.lockSwipes(true);
//let currentIndex = this.quizSlider.getActiveIndex().then( (val) => console.log(val) );
//console.log('Current Slide: ' + currentIndex);
//this.quizSlider.slideTo(questionNo + 1);
}
}
}
1 post - 1 participant