Riron / ionic-img-viewer

Ionic 2+ component providing a Twitter inspired experience to visualize pictures.
MIT License
283 stars 118 forks source link

adding imageViewer to the img tag does not work #117

Open Shivani-Parihar opened 6 years ago

Shivani-Parihar commented 6 years ago

Please provide you version information :

Dependency Version
ionic2 3.18.0
angular 5.2.9
ionic-img-viewer 2.9.0

I was able to get it working with creating my own instance of imageViewer

<img src="assets/imgs/bilirubin.png" #myImage (click)="zoomImage(myImage)" />
zoomImage(myImage) {
    const imageViewer = this._imageViewerCtrl.create(myImage);
    imageViewer.present();
    console.log(myImage);

    setTimeout(() => imageViewer.dismiss(), 5000);
  }

But as my app works, I have to get it working with just adding the imageViewer to img tag which does not work. Can you help out with why the below method does not work

<img src="assets/imgs/bilirubin.png" imageViewer />
Bleno commented 6 years ago

+1

Riron commented 6 years ago

Hey, Do you have any error in the console ?

kamran377 commented 6 years ago

Add the IonicImageViewerModule to your page' smodule.ts like this

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { DemoPhotoShootPage } from './demo-photo-shoot';
import { TranslateModule } from '@ngx-translate/core';

import { IonicImageViewerModule } from 'ionic-img-viewer';
@NgModule({
  declarations: [
    DemoPhotoShootPage,
  ],
  imports: [
    IonicPageModule.forChild(DemoPhotoShootPage),
    TranslateModule.forChild(),
    IonicImageViewerModule,
  ],
})
export class DemoPhotoShootPageModule {}

After this it works fine :)