Umaiz Khan
Umaiz Khan

Reputation: 1227

ionic 4 how to change slide by click on button

I am using slides but I need to change the slide on button click.

Example Code

<ion-slides>
  <ion-slide>
   Slide one 
  <ion-slide>

  <ion-slide>
   Slide Two
  <ion-slide>
</ion-slides>
<button (click)="next()" >Next</button>

I need to change the slide when i click on next button thanks

Upvotes: 1

Views: 2028

Answers (1)

Melchia
Melchia

Reputation: 24314

Here's an example to use it :

<ion-slides #slides>
  <ion-slide>
   Slide one 
  <ion-slide>

  <ion-slide>
   Slide Two
  <ion-slide>
</ion-slides>
<button (click)="next(slides)" >Next</button>

in your ts file, add the method for next:

next(slides){
    slides.slideNext(); // slide to next
}

If you want to slide to previous use slidePrev(). Here's the documentation about slides.

Upvotes: 2

Related Questions