Skip to content

Instantly share code, notes, and snippets.

@ponnex
Last active May 7, 2018 23:31
Show Gist options
  • Select an option

  • Save ponnex/9531106feb1e547dfbf2c1b158946d36 to your computer and use it in GitHub Desktop.

Select an option

Save ponnex/9531106feb1e547dfbf2c1b158946d36 to your computer and use it in GitHub Desktop.
// Camera Service
onTakePhoto() {
return new Promise((resolve, reject) => {
requestPermissions().then(
() => {
// Other Codes Here
takePicture(options)
.then((imageAsset: any) => {
// Other Codes Here
});
return resolve(this.imageTaken);
}).catch(err => {
return reject(err);
});
},
() => return reject(err);
);
});
}
// Component
this._cameraService.onTakePhoto().then((imageAsset: ImageAsset) => {
this.priceListImage = imageAsset; // <- the ImageAsset from Service ;)
}).catch(err => {
// Do something here when there's an error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment