I'm trying to get a photo from the user's camera or gallery using phonegap 3.0.0 (+angular)
For some reason, it works only for a photo taken captured by the camera
This is my HTML:
<button ng-click="getPhoto(0);">0</button><br>
<button ng-click="getPhoto(1);">1</button><br>
<button ng-click="getPhoto(2);">2</button><br>
<img ng-src="{{preview}}" />
Where the parameter of getPhoto
is phonegap's PictureSourceType
Camera.PictureSourceType = {
PHOTOLIBRARY : 0,
CAMERA : 1,
SAVEDPHOTOALBUM : 2
};
And the code in the Javascript (Angular's control) is
$scope.preview="";
$scope.getPhoto= function(source) {
navigator.camera.getPicture(function(imageURI)
{
$scope.preview=imageURI;
},function(message) {
alert('Failed because: ' + message);
},
{
quality: 50,
destinationType: 1,
sourceType: source
});
}