I have an issue with the ion-slides component. I'm calling a method within my ion-slide
but noticed that this method is called RIDICULOUSLY OFTEN and i'm not sure why. It also slows everything down significantly.
Initially the method is called 900 times (even though i'm only showing 100 slides) and the slightest drag of the slides again triggers 900 method calls, so by just swiping from the first to the second slide the method has been triggered 5000+ times, depending on how slowly I swipe.
Any ideas why? I'm using Ionic 4.4, Angular 5.0.3 and Ionic-Angular 3.9.2.
Template
<ion-content>
<ion-slides>
<ion-slide *ngFor="let slide of slides">
<div>
{{slide}} - {{myMethod()}}
</div>
</ion-slide>
</ion-slides>
</ion-content>
Component
@Component({
selector: 'page-my',
templateUrl: 'my-page.html'
})
export class MyPage implements OnInit {
slides: number[] = [];
methodCounter: number = 0;
ngOnInit() {
let numberOfSlides = 100;
for (var i = 0; i < numberOfSlides; i++) {
this.slides[i] = i;
}
}
public myMethod(): string {
console.log('myMethod called ' + this.methodCounter++);
return 'foo';
}
}