I have the below code in my view. I am displaying the selected image in the IMG tag.
The logic works fine. But I am facing a problem where after the binding is done, the image does not show up immediately. When I navigate to some other page and come back to the actual page, the image shows up.
Ideally the image should be shown as soon as I select the image from the gallery.
<div class="list card" ng-hide="imageUrl == null">
<div class="item">
<h2>Preview</h2>
</div>
<div class="item item-body">
<img id="imgDiv" class="full-image" alt="Selected Image" src="{{imageUrl}}" />
</div>
</div>
Below is the controller logic.
$scope.takeCamera = function() {
navigator.camera.getPicture(fromGallery, null, {
quality: 50,
destinationType: navigator.camera.DestinationType.DATA_URL,
allowEdit: true
});
}
fromGallery = function(imagedata) {
$scope.imageData = imagedata;
if (imagedata !== "") {
$scope.imageUrl = "data:image/jpeg;base64," + imagedata;
} else {
alert("No Valid Image");
}
}
There are several others pages where I have this issue. Any help would be really appreciated.
Thanks in advance.