Cordova Camera Plugin Not Working w/ AngularJS

Trying to get the Cordova Camera to work. I’ve upgraded to the latest apache cordova camera plugin to handle issues with IOS8. Now I get issues stating:
“getPicture()” undefined from the Camera class (refer to the Camera Sample here

Also, in another project I get an error when I use the options as such in the Angular Controller
"Camera.DestinationType.DATA_URL" --> Says Camera is undefined whenever I use the ngCordova plugin…Essentially, it’s quite weird. When I simply replace the attribute with it’s value of 0 the error doesn’t happen but the camera still does not popup.

Any way to solve this?

If I can give you an advice, remove the plugin installed by
cordova plugin remove
and install with :
cordova plugin add

I did this…Did further digging and found out that the “” object nor the Camera class is defined in the app itself. I’m doing debugging on the IOS Phone via Safari browser. I pulled the latest version of the plugin…In the nGCordova, the promise object returns null if “” is undefined, and null is exactly what I get form my getPicture() below.

If this has worked for you, what repo did you pull from to get the latest camera plugin and how did you do the include in Angular so that it’s in view? I’ve done the Camera module include already and still doesnt work for me.

Code Snippet:
angular.module(‘controllers.profile’, [‘’])

.controller(‘ProfileCtrl’, [
function($cordovaCamera, $cordovaLocalStorage, $ionicActionSheet, $ionicModal, $ionicLoading, $ionicPopup, $timeout, $scope, $state, $stateParams, $ionicPlatform, Constants, AuthService, Utils,Camera) {
var options = {};
$ionicPlatform.ready(function() {
$scope.openCamera = function(){
$cordovaCamera.getPicture(options).then(function(imageData) {
//$scope.imgURI = “data:image/jpeg;base64,” + imageData;
}, function(err) {
// An error occured. Show a message to the user
console.log("Error: "+err);


Here is my code :

'use strict';

 * editaccount controller: 
angular.module('lio').controller('editaccountCtrl', function ($scope, $ionicGesture, $state,
                                                                appConstants) {

    // get a working copy of the object
    $scope.user = JSON.parse(JSON.stringify(UserService.user()));

    $scope.changePicture = function() {, onFail,
                sourceType : Camera.PictureSourceType.CAMERA,
                correctOrientation: true,
                quality: 75,
                targetWidth: 200,
                destinationType: Camera.DestinationType.DATA_URL,
                encodingType: Camera.EncodingType.PNG,
        function onSuccess(imageData) {
            $scope.user.picture = "data:image/png;base64," + imageData;

        function onFail(message) {
            if (appConstants.debug) {
                alert('Failed because: ' + message);



I didn’t try on iOS because don’t have an iOS phone, but it should works. (Works on Android).

Thank you.
I actually got it working…cordova.js was defined after ng-cordova.js. Love it when the biggest debugging time consumer is always from something simple. Thanks.

1 Like

glad to hear that.
Have a nice week end.

1 Like