Ionic slider + loop + click event issue

hello friends,
I am using slider with dynamic data using property loop and autoplay

<ion-slides *ngIf="slides != null" loop="true"> <!-- autoplay="3000" loop="true" speed="800"-->
        <ion-slide *ngFor="let slide of slides; let i = index ;" >
            <img [src]="slide.BannerImage" (click)="fnGotoNewArrivalList(i)">
            <div class="con-box">

import { ViewChild } from '@angular/core';
import { Slides } from 'ionic-angular';

 @ViewChild(Slides) myslides: Slides;

slideChanged() {
    let currentIndex = this.myslides.getActiveIndex();
    alert('Current index is ' + currentIndex);
    alert(JSON.stringify(collectionid ));

Button/Click does not work when going from last slide to first slide
slide next and slide previous both scenario.

NOTE - its working fine without loop property

thank you,

Hi, @spanchal

Could you check


1 Like

@addwebsolution thanks :slight_smile:

I have already tried.
but when apply loop to slider that time index not work proper :worried: otherwise its working fine.

hello friends,

I have one alternate solution for slider click event issue,
using swiper I have solved this issue
follow this steps for implement swiper slider.

install “npm install angular2-swiper-wrapper --save-dev”

 <swiper class="swiper-container" [config]="config">
        <div *ngFor="let slide of slides">
            <div class="swiper-slide">
                <div class="detail-con-box">
                    <button ion-button color="btn" (click)="fnGotoNewArrivalList(slide.CollectionID,slide.BannerName)">Order Now</button>

=========== .ts file ===============
this.config = {
         speed: 1000,
        paginationClickable: true,
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: 2500,
        autoplayDisableOnInteraction: false,
        initialSlide : 0,
        slidesPerView: 1,
        effect: 'slide',
        // paginationType: 'progress',
        // pagination: '.swiper-pagination',
        // nextButton: '.swiper-button-next',
        // prevButton: '.swiper-button-prev',

Thank you. :slight_smile: