Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open the image gallery with Ionic/angularjs

How do I access with Ionic/angularjs on the image gallery? I just want to open the image gallery per button click. How is that possible?

like image 742
Ramosta Avatar asked Jun 21 '26 22:06

Ramosta


1 Answers

You can use the cordova camera plugin

cordova plugin add org.apache.cordova.camera

Plugin Reference: https://github.com/apache/cordova-plugin-camera

Sample code

$scope.getPhoto = function() {

    var options = {
        quality: 50,
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
        mediaType: Camera.MediaType.ALLMEDIA,
        saveToPhotoAlbum: true

    };

    $cordovaCamera.getPicture(options).then(function(imageData) {
        console.log("img URI= " + imageData);        
        //Here you will be getting image data 
    }, function(err) {
        alert("Failed because: " + err);
        console.log('Failed because: ' + err);
    });

};

You need to just set sourceType option to Camera.PictureSourceType.SAVEDPHOTOALBUM

like image 180
Bhavesh Jariwala Avatar answered Jun 24 '26 22:06

Bhavesh Jariwala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!