Skip to content

Instantly share code, notes, and snippets.

@geykel

geykel/home1.ts Secret

Last active Aug 2, 2017
Embed
What would you like to do?
import { Component } from '@angular/core';
// 1
import { Platform } from 'ionic-angular';
// 2
import { DomSanitizer } from '@angular/platform-browser';
// 3
import { Camera, CameraOptions } from '@ionic-native/camera';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
// 4
base64Image: string;
// 5
constructor(
public platform: Platform,
public camera: Camera,
public domSanitizer: DomSanitizer) {
}
// 6
takePicture() {
// 7
this.platform.ready().then(() => {
// 8
const options: CameraOptions = {
destinationType: this.camera.DestinationType.DATA_URL,
quality: 75
};
// 9
this.camera.getPicture(options).then((imageData) => {
// 10
this.base64Image = 'data:image/jpeg;base64,' + imageData;
}, (error) => {
// 11
console.log(error);
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment