Book Image

Ionic Cookbook

By : Hoc Phan
Book Image

Ionic Cookbook

By: Hoc Phan

Overview of this book

Table of Contents (18 chapters)
Ionic Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Taking a photo using the device camera


For this recipe, you will make an app to take a picture using the device camera or load an existing picture from the device album. The picture could be either in Base64 format or saved in a local filesystem of your app. Here is the high-level process:

  • Access the Cordova Camera plugin to trigger camera capture and get the image back in the Base64 or file URI format

  • Parse the Base64 data or URI on a <img> DOM object

  • Display URI if it's in the URI format

  • Capture an event of a toggle component

  • Display long data (for example, URI) using horizontal scroll

Getting ready

You should have a physical device ready in order to test camera capability. It's possible to just run it via an emulator, but the filesystem support might look different across platforms.

This section also requires Bower to be installed. Bower is a utility to help you manage packages for the frontend. It makes installing packages easier because you don't have to hunt all over the place for correct...