Search code examples
javascripthtmlangulartypescriptngx-gallery

ngx-gallery preview open : get index of image opened and cancel preview opening


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!


Solution

  • 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.
        }
      },
      ...
    ];