Ionic Slides not working with await/async

201 views Asked by At

I'm using Ionic's slides component (based on Swiper) and it works great. However, I have a specific use case where I need to set the slider's spaceBetween option based on an async call.

I tried using the .update() method but without any effect.

public sliderOptions: Slider = {
    spaceBetween: 0
}

async ngOnInit() {
    await this.getDocuments();
}

async function getDocuments() {
    //this.sliderOptions.spaceBetween = -75; (HERE IT WORKS)

    let response = await this.service.getDocuments();

    this.sliderOptions.spaceBetween = -75; // DOESN'T WORK
    this.slides.update().then(() => console.log('SLIDER UPDATED'));
}

<ion-slides #slides [options]="sliderOptions">
....
</ion-slides>

What am I doing wrong?

0

There are 0 answers