@IreneC wrote:
Hi!
I am trying to take a photo using Camera plugin. But when I click a button to take the photo nothing happens. I tried to debug on device and nothing happens.
I am working with Android.
My HTML code is:
<ion-content> <div class="center-item"> <ion-button color="light" shape="round" click="takePhoto()"> {{ 'tab2.takePhotoButton' | translate }} </ion-button> <img [src]="imageUrl"/> </div> </ion-content>My ts code is:
/** * Camera options. */ private options: CameraOptions = { quality: 100, destinationType: this.camera.DestinationType.DATA_URL, encodingType: this.camera.EncodingType.JPEG, mediaType: this.camera.MediaType.PICTURE } private imageUrl:string; constructor(private camera: Camera) {} takePhoto() { this.camera.getPicture(this.options).then((imageData) => { console.log("hola"); // imageData is either a base64 encoded string or a file URI // If it's base64 (DATA_URL): let base64Image = 'data:image/jpeg;base64,' + imageData; this.imageUrl = base64Image; console.log(this.imageUrl); }, (err) => { // Handle error }); }Can anyone help me?
Posts: 1
Participants: 1