My ion-slides
were hardcoded in the HTML page.
So, I had packed the slides data into an array in the ts
file and looped the ion-slide
tag using *ngFor
with 1s delay after the ionViewWillLoad()
had fired.
TS code:
...
slides = null;
...
ionViewWillEnter() {
setTimeout(() => {
this.slides = [
{
imgSrc: "...",
header: "...",
text: "...",
action: "skip"
},
{
imgSrc: "...",
header: "...",
text: "...",
action: "skip"
},
{
imgSrc: "...",
header: "...",
text: "...",
action: "skip"
}
]
}, 1000);
}
HTML code:
<ion-slides *ngIf="slides" pager>
<ion-slide *ngFor="let slide of slides">
<img [src]="slide.imgSrc" class="slide-image" />
<h2 class="text-heading">{{ slide.header }}</h2>
<p class="text-light" text-capitalize [innerHTML]="slide.text"></p>
<span (click)="goToMenu()" class="text-light" text-capitalize>{{ slide.action }}</span>
</ion-slide>
</ion-slides>