Cordova App : Image not showing

时间:2017-04-13 14:57:11

标签: javascript cordova

In my app I have a functionality of clicking an image from camera plugin and then navigate to a different view and show the image there. I am saving the dataurl of the image in localStorage and then in the other view I am calling the getItem method to get the dataurl of the image clicked. After that I am assigning this dataurl to src of the image to be shown in the view.
But the problem is that the image is not showing!!
I checked the localstorage while debugging, the dataurl is there under localStorage. What can be the problem, and how to solve it ??

Controller for initiating the camera...

init_camera: function() {
    var controller = this;
    navigator.camera.getPicture(onSuccess, onFail, { 
        quality: 80,
        destinationType: Camera.DestinationType.DATA_URL
    });
    function onSuccess(imageData) {
        var image = document.getElementById('myImage');
        image.src = "data:image/jpeg;base64," + imageData;
        localStorage.setItem('initial', image.src);
        controller.redirectTo('Preview');
    }
    function onFail(message) {
        alert('Failed because: ' + message);
    }
}

Code to get the dataurl in the other view.. (in ExtJS)

items: [{
    xtype: 'image',
    cls: 'prev_img',
    src: localStorage.getItem('initial'),
    flex: 2
},

0 个答案:

没有答案