Ionic 2 Change date with swipe don't work


#1

Hey everyone,

I’m trying change date with my slide but don’t work. I’m using moment.js lib

   addDate() {
    this.currentDate = moment(this.currentDate, this.formatDate).add(1, 'days').format(this.formatDate);
    }

    <ion-row center>
		<ion-slides (ionSlideNextStart)="addDate()" (ionSlidePrevStart)="rmDate()">
		  <ion-slide>  
            {{currentDate}}
		  </ion-slide>
		</ion-slides>
    </ion-row>

It only adds one day and then it doesn’tt work.

Any help, helps.

Best


#2

Hey guys,

I found the solution.

thanks everyone.

results.html




		<ion-slides>
		  <ion-slide (swipe)="swipeEvent($event)">  
	        {{currentDate}}
		  </ion-slide>
		</ion-slides>

results.ts

   swipeEvent(e) {
     if (e.direction == 2) 
     {
      console.log('swiped left');
      
       this.addDate();
     } else if (e.direction == 4) 
     {
       console.log('swiped right');

       this.rmDate();
     }
    
  }