finalized v4 code
This commit is contained in:
@@ -5,12 +5,18 @@
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<img [src]="currentImage" *ngIf="currentImage">
|
||||
<ion-grid>
|
||||
<ion-row>
|
||||
<ion-col size="6" *ngFor="let photo of photoService.photos">
|
||||
<img [src]="photo.data" />
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
|
||||
<ion-fab vertical="bottom" horizontal="center" slot="fixed">
|
||||
<ion-fab-button (click)="takePicture()">
|
||||
<ion-icon name="camera"></ion-icon>
|
||||
</ion-fab-button>
|
||||
<ion-fab-button (click)="photoService.takePicture()">
|
||||
<ion-icon name="camera"></ion-icon>
|
||||
</ion-fab-button>
|
||||
</ion-fab>
|
||||
|
||||
</ion-content>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
||||
import { PhotoService } from '../services/photo.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-about',
|
||||
@@ -9,23 +9,10 @@ import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
||||
export class AboutPage {
|
||||
currentImage: any;
|
||||
|
||||
constructor(private camera: Camera) { }
|
||||
constructor(public photoService: PhotoService) { }
|
||||
|
||||
takePicture() {
|
||||
const options: CameraOptions = {
|
||||
quality: 100,
|
||||
destinationType: this.camera.DestinationType.DATA_URL,
|
||||
encodingType: this.camera.EncodingType.JPEG,
|
||||
mediaType: this.camera.MediaType.PICTURE
|
||||
}
|
||||
|
||||
this.camera.getPicture(options).then((imageData) => {
|
||||
// imageData is either a base64 encoded string or a file URI
|
||||
this.currentImage = 'data:image/jpeg;base64,' + imageData;
|
||||
}, (err) => {
|
||||
// Handle error
|
||||
console.log("Camera issue:" + err);
|
||||
});
|
||||
ngOnInit() {
|
||||
this.photoService.loadSaved();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user