After reading all the related post on Stack OverFlow and other sites, including Ionic documentation, I am not able to get this working. I have tried to replicate the same so currently I have:
In app.module.ts
import { PhotoViewer } from '@ionic-native/photo-viewer/ngx';
and
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
PhotoViewer
],
bootstrap: [AppComponent]
})
export class AppModule {}
in home.page.ts
import { PhotoViewer } from '@ionic-native/photo-viewer/ngx';
export class HomePage {
constructor(private photoViewer: PhotoViewer) { }
openImage() {
this.photoViewer.show(''../assets/baluarte.jpg');
}
}
and in home.page.ts
<ion-content padding>
<img src="../assets/baluarte.jpg" (click)="openImage()"/>
<ion-button (click)="openImage()">View</ion-button>
</ion-content>
What I would like to achieve is to have the picture displayed and when I click as Ionic mentions your image in full screen with the ability to pan, zoom, and share the image. However, I'm trying at the same time to have a button with the same function just to be sure that the error is not in the image.
Also inside
this.photoViewer.show(''../assets/baluarte.jpg');
I am trying also with a URL since I'm not sure it could work with local file, but it is also not working
this.photoViewer.show('https://images.app.goo.gl/cW8jBeX33H9GKAon9.jpg')
My final goal is to use a local file.
Of course I installed
ionic cordova plugin add com-sarriaroman-photoviewer
npm install @ionic-native/photo-viewer