ngCordova : $cordovaCamera is undefined

Hi there,

I’m trying to implement picture capture with ngCordova. So I followed this list

  1. Install apache cordova plugin

  2. Add ios param in config.xml

  3. download js ng-cordova and link it to my index

  4. declare ‘ngCordova’ plugin in my app

  5. Implement camera test in my controller

    $scope.takePicture = function() {

    if (typeof $cordovaCamera == ‘undefined’)
    {$ = ‘’;
    console.log(‘Camera not found’);}
    quality: 75,
    targetWidth: 320,
    targetHeight: 320,
    saveToPhotoAlbum: false
    }).then(function(imageURI) {
    $ = imageURI;
    }, function(err) {
    console.error(‘Unable to take pic’, err);
    alert(‘Unable to take picture’);

  6. No error in Web console, except $cordovaCamera is undefined, that is normal I guess

But when I try to test it on IOS device, I get exactly the same thing than web : $cordovaCamera is undefined.

Any advice on this ?

Did you add $cordovaCamera it in your controller declaration ? Just like:

my_app.controller('MyCtrl', function($scope, $cordovaCamera) {
  // Your picture function here

Yes, I put it. I’ve tested on android and on iOS it doesn’t work

Testing with phonegap code from ducmentation

    function capturePhoto() {
  // Take picture using device camera and retrieve image as base64-encoded string, onFail, { quality: 50,
    destinationType: destinationType.DATA_URL });

It works like a charm on both IOS and Android, I think I miss something with ng-cordova.

How did you get the ng-cordova.js file ? The custom build had generated an invalid file for me… I had to download the file from github and it worked.

Yes, I read your post because I got a ‘ngCordova’ module not found error. So I directly downloaded the raw version from Github and this error disappeared.

Actually, if you put in your angular app “ngCordova”, but launch a custom build for the camera plugin, the module will be named “”, so that’s the reason why it wasn’t found.

Interesting, I will give a try to test with a custom build
I keep you informed

The problem is that with a custom build the ngCordova module is not created.

OK it works guys.
I downloaded a custom build, and declare “” plugin.
Xcode told me it doesn’t find Camera device, so I removed cordova camera plugin and add it again (a kind of refresh) and camera capture works fine.

Thanks for your support !