I’m having trouble referencing my slider to use the ‘SlideNext’ method, resulting in an undefined error. I’m using Ionic 4 Angular.
import { Component, OnInit, ViewChild } from '@angular/core';
import { IonSlides } from '@ionic/angular';
@Component({
selector: 'app-calculator',
templateUrl: './calculator.component.html',
styleUrls: ['./calculator.component.scss'],
})
export class CalculatorComponent implements OnInit {
@ViewChild('slider', { read: IonSlides }) slides: IonSlides;
slideOpts = {
pagination: {
el: '.swiper-pagination',
type: 'progressbar',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
};
constructor() { }
ngOnInit() {}
slideNext() {
console.log(this.slides);
this.slides.slideNext();
}
}
<ion-slides #slider [options]="slideOpts" pager>
<ion-slide>
<h1 class="mt-0">Slide 1</h1>
</ion-slide>
<ion-slide>
<h1 class="mt-0">Slide 2</h1>
</ion-slide>
<ion-slide>
<h1 class="mt-0">Slide 3</h1>
</ion-slide>
</ion-slides>
Any ideas where I might be going wrong?