0

I want to open a matdialog with the index of the image, by overriding the previewOpen() method: it should not open the original (big image) preview but opens a matdialog instead (which I already have the code for).

  <ngx-gallery (previewOpen)="openPreview(index)" [options]="galleryOptions" [images]="galleryImages" class="ngx-gallery"></ngx-gallery>

Is there any way I can achieve this ?

THanks in advance!

Mich
  • 182
  • 3
  • 6
  • 21
  • Can you create a working example on Plunker or on Stackblitz? – Julian W. May 16 '21 at 14:03
  • @JulianLiu like this, https://stackblitz.com/edit/kolkov-ngx-gallery?file=src%2Fapp%2Fapp.component.ts what I want is when I click on the image, the preview doesnt open and instead I use another method with the index of the image as a parameter – Mich May 16 '21 at 14:12

1 Answers1

1

You should use previewCustom property of NgxGalleryOptions.

So the code should look like the following.

this.galleryOptions = [
  ...,
  {
    previewCustom: () => {
      // To Do: Your custom preview function here.
    }
  },
  ...
];
Julian W.
  • 1,501
  • 7
  • 20
  • You can check it at https://stackblitz.com/edit/kolkov-ngx-gallery-abllhr I just added `console.log` there. – Julian W. May 16 '21 at 14:26
  • Thank you very much. really appreciated and saved me a lot of time ! can you tell me where you found the answer ? – Mich May 16 '21 at 14:28
  • Also, is there any similar method for right and left arrows ? something like previewCustomNextArrow: (index) => {console.log(index)} – Mich May 16 '21 at 14:43
  • I checked the source code of the library. https://github.com/lukasz-galka/ngx-gallery/blob/master/src/ngx-gallery.component.ts – Julian W. May 16 '21 at 14:44
  • Thanks! Its working properly. But I've been looking for a way to override the showNext() and showPrev() methods but haven't been succesfull yet. Could you lend me a hend ? I've tried to make a @ViewChild(NgxGalleryComponent) gallery: NgxGalleryComponent; so now I can call the gallery.image.showNext() but don't know how to override/implement my own method for the arrows. – Mich May 16 '21 at 15:27