ngCordova Camera Error - HEPL!

i dont know what to do anymore… i’ve tried everything and i have no idea what i’m doing wrong.
im using ionic-yeoman framework and im trying to use ng-cordova plugins to get access to the camera.
at this point i just want to open the camera. i have no idea what to do next since the code doesn’t seems to do anything.
please help me!!! its been over a week and i can’t find a solution!@#$%^&*.

this is my controler

.controller(‘profileCtrl’, function($scope, myService, $cordovaCamera) {

var Camera = navigator.camera;

  $scope.takePicture = function() {
	$cordovaCamera.getPicture(onSuccess, onFail, { quality: 50, destinationType: $cordovaCamera.FILE_URI }); 

	function onSuccess(imageURI) {
		console.log('asdasd');
	}

	function onFail(message) {
		console.log('asdasd');
	}
	
	console.log('asdasd');
  
  
myService.getFoo().then(function(data) {
   //this will execute when the 
   //AJAX call completes.
   $scope.items = data;
});

})

I haven’t tried ionic-yeoman.

But $cordovaCamera takes the "options" as the argument and then it returns the promise to handle success and failure cases. Have you tried that?

did you review the documentation? There is an example there, and what you have above does not reflect how the camera is documented in ngCordova

http://ngcordova.com/docs/

$cordovaCamera.getPicture(options).then(function(imageData) {
  // Success! Image data is here
}, function(err) {
  // An error occured. Show a message to the user
});

Hey @Matangub i think @aaronksaunders is right.

It seems that you mixed up cordovaCamera with original phonegap camera plugin syntax.
Ionic uses promises to handle asynchronous calls.

Greetz, bengtler

i copied the code from the ngCordova example. but it gives me the next error:
ReferenceError: Camera is not defined

got any idea how to fix this? i also saw you replied to my stackoverflow post. mind if i’ll add you to skype so we can help each other? realy need someone that will help me…

Sure you are testing your code on a mobile device?

If you try to test this on non-mobile browser there will be no Camery object on the window object.

Greetz, bengtler

AHHH !@#!@#!@#!@#
ITS FINALLY WORKING.
CAN’T BELIVE THAT WAS THE ERORR T_T I WANNA SHOORT MYSELF I THE HEAD…

there is no words how grateful i am… THANK YOU MAN!

for any future developers who will get this error:ReferenceError: Camera is not defined - you need to build and run on device.

For this purposes you can check if “window.cordova” is there.
If not your are not on a real mobile device :wink:

Hello,

something more (since I wasted time, this could help someone else). You have to wait for the deviceready event before using the plugins, and that is not automatically done. See this topic :

I used the solution given by Natsu- and it actually works like a charm.

Good luck !

is anyone else gettign the same error where it returns the same broken data URI with every picture