0

Ionic gallery album

I can able to view all the images in grid format,if i select one among them,i need to start the ionic slide image from that..

SAMPLE CODE

<ion-slides zoom="true">
    <ion-slide *ngFor="let img of images.imageUrl>
      <div class="swiper-zoom-container">
        <img style="max-width: 95%;" [src]="img.url" (click)="downloadicon()"/>
      </div>
      <span class="icon-save notify" *ngIf="showimage" (click)="downloadImage(img.url,img.public_id)"></span>
    </ion-slide> 
  </ion-slides>

NOTE:

images.imageUrl - array which contain all images

1

3 Answers 3

1

You can call goToSlide() on your click event-

class MyPage {
  @ViewChild(Slides) slides: Slides;

  goToSlide() {
    this.slides.slideTo(2, 500);
  }
}
Sign up to request clarification or add additional context in comments.

Comments

0

Need to start loop *ngFor from given array index

<ion-slides zoom="true">
        <ion-slide *ngFor="let img of images.imageUrl | slice:index ">
          <div class="swiper-zoom-container">
            <img style="max-width: 95%;" [src]="img.url" (click)="downloadicon()"/>
          </div>
          <span class="icon-save notify" *ngIf="showimage" (click)="downloadImage(img.url,img.public_id)"></span>
        </ion-slide> 
      </ion-slides>

1 Comment

Thanks for your response..i don't want to slice a array...i just want to start with given array index example: if the index is 2,i can able to swipe right and see further images. that's fine.. but if i swipe to left i need to view index 0,1 images
0

I would say that there are 2 options

  1. simply you need make another array when user selects one. and just use the array in template.

  2. when user selects one, save the index number. and add condition in ngFor like below :

I hope this would be helpfule

<ion-slide *ngFor="let img of images.imageUrl | slice:index ">

or

<ion-slide *ngFor="let img of images.imageUrl;let row = index">
        <div *ngIf="row > selectedIndex">
            ...
        </div>
    </ion-slide>

1 Comment

Thanks for your response..i don't want to slice a array...i just want to start with given array index example: if the index is 2,i can able to swipe right and see further images. that's fine.. but if i swipe to left i need to view index 0,1 images

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.