I pulled the example from the ngCordova website but I cannot get this to work. All I want for hours now is to simply take a picture with the camera! The app loads (Don’t know if without errors) but nothing happens.
I also tried to uninstall plugins/libs/plattforms and start over. I tried $cordovaCamera.DestinationType.DATA_URL
but no luck.
Here is my Code
App.controller('HomeController', ['MomentJsService', function(MomentJsService, $cordovaCamera) {
var vm = this;
vm.image = "foo";
console.log($cordovaCamera); // undefined
document.addEventListener("deviceready", function () {
console.log('ready'); // how would you find out what this logs? I'm using ionic view app and ios simulator.
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL, // Camera is undefined
sourceType: Camera.PictureSourceType.CAMERA, // Camera is undefined
allowEdit: true,
encodingType: Camera.EncodingType.JPEG, // Camera is undefined
targetWidth: 100,
targetHeight: 100,
// popoverOptions: CameraPopoverOptions, // undefined
saveToPhotoAlbum: false,
correctOrientation:true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
vm.image = "data:image/jpeg;base64," + imageData;
}, function(err) {
// error
});
}, false);
// here is where I actually want it
// vm.addImage = function() {
// }
}]);
Any idea what could be wrong?