-1

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
                                });
}
Uri Goren
  • 13,386
  • 6
  • 58
  • 110

1 Answers1

-1

Get photo from PHOTOLIBRARY

  navigator.camera.getPicture(function(imageURI)                                {
                                $scope.preview=imageURI;
                        }, function(message) {
                                alert('Failed because: ' + message);
                        }, { quality: 50,destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY});
Ved
  • 2,701
  • 2
  • 22
  • 30
  • this expression `navigator.camera.PictureSourceType.PHOTOLIBRARY` is a long way to write `0`. Why should it have any effect ? – Uri Goren Dec 07 '13 at 13:38