How to take a picture and save

I’m trying to use the camera android, but I can not I will mouth the step by step example of ionic, but does not work follows the code


// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers'])

    .run(function ($ionicPlatform) {
        $ionicPlatform.ready(function () {
            // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
            // for form inputs)
            if (window.cordova && window.cordova.plugins.Keyboard) {
            if (window.StatusBar) {
                // org.apache.cordova.statusbar required


    .config(function ($stateProvider, $urlRouterProvider, $compileProvider) {



    .state('', {
        url: "/camera",
        views: {
            'menuContent': {
                templateUrl: "templates/camera.html",
                controller: 'CameraCtrl'

// if none of the above states are matched, use this as the fallback


angular.module('starter.controllers', [])

.controller('CameraCtrl', function($scope, Camera) {

    $scope.getPhoto = function() {
        Camera.getPicture().then(function(imageURI) {
            $scope.lastPhoto = imageURI;
        }, function(err) {
        }, {
            quality: 75,
            targetWidth: 320,
            targetHeight: 320,
            saveToPhotoAlbum: false



angular.module('', [])

    .factory('Camera', ['$q', function($q) {

      return {
        getPicture: function(options) {
          var q = $q.defer();

            // Do any magic you need
          }, function(err) {
          }, options);

          return q.promise;


<ion-nav-bar class="bar bar-balanced" id="box-shadow-top">
    <button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
    <h1 class="title"><i class="icon ion-ios-camera"></i> Camera</h1>
<ion-view >
    <ion-content padding="true" class="has-header" scroll="true" ng-controller="CameraCtrl">
        <button ng-click="getPhoto()" class="button button-block button-primary">Take Photo</button>
        <img ng-src="{{lastPhoto}}" style="max-width: 100%">

In the index, I make the calls the necessary files normally

1 Like

Here is an example

Complete Project :
Camera Usage:

with one service that saves the image locally and one that saves it to Parse.

I was looking at your code and I dont understand why you are not using ngCordova, $cordovaCamera.getPicture since you said you reviewed the learn.ionic sample?


Awesome… thank you

1 Like

Wow, would you be able to make one for Ionic 3?

Ionic 2 codes are no longer valid…


1 Like