Store Image into internal Storage in Ionic?

2019-09-01 10:59发布

问题:

i am new in Ionic, i am trying to get picture and want to store copy or store image into internal storage so i can get back captured image on any view. I don't know how to store images in internal Storage. I have read this.

this is Helpful but not solving my issue. My Controller is here. Help me in this.

Controller

/**** tab  Camera Controller ***/
.controller('tabCameraCtrl', function($scope, $state, $cordovaCamera) {

    /**********function to Open Camera *********/
     $scope.openCamera = function() {
        document.addEventListener("deviceready", function() {
            var options = {
                quality: 50,
                destinationType: Camera.DestinationType.FILE_URI,
                sourceType: Camera.PictureSourceType.CAMERA,
                // allowEdit: true,
                //encodingType: Camera.EncodingType.JPEG,
                targetWidth: 100,
                targetHeight: 100,
                //popoverOptions: CameraPopoverOptions,
                saveToPhotoAlbum: false
               // correctOrientation: true
            };
            $cordovaCamera.getPicture(options).then(function(imageURI) {
                var image = document.getElementById('myImage');
                image.src = imageURI;
                $scope.lastPhoto = imageURI;
                window.localStorage.setItem('image',JSON.stringify(imageURI));
                console.log('success')
                console.log('Image Address');
                console.log(imageURI);

            }, function(err) {
                // error
                console.log(err)
            });
        }, false);
    }

Help me to solve this problem.