I make a controller to take or set photo and then upload with ngcordova plugin.
Is it possible to convert into service so I could use every time calling ng-click="takePhoto"?
This is my controller:
.controller('CameraCtrl', function ($scope, $cordovaCamera, $ionicLoading, $localstorage) {
//$scope.data = { "ImageURI" : "Select Image" };
$scope.takePicture = function() {
var options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URL,
sourceType: Camera.PictureSourceType.CAMERA
};
$cordovaCamera.getPicture(options).then(
function(imageData) {
$scope.picData = imageData;
$scope.ftLoad = true;
$localstorage.set('fotoUp', imageData);
$ionicLoading.show({template: 'Foto acquisita...', duration:500});
},
function(err){
$ionicLoading.show({template: 'Errore di caricamento...', duration:500});
})
}
})
I'll try by myself but when I put into services.js return this error:
ReferenceError: Camera is not defined