Search code examples
angularjshtmlcordovaionic-frameworkngcordova

Display images from sdcard in Ionic app


I want to display images from sdcard in my Ionic application , But I got problem to show images with img tag.

View Code For My Application

<ion-content ng-controller="DigitalCatCtrl">
<div>
       <img ng-src="{{myimg}}" />
       <img src="{{myimgs}}" />
</div>
</ion-content>

Controller Code For My Application

.controller('DigitalCatCtrl', function($scope,$cordovaFile) {
      $scope.myimg=cordova.file.externalRootDirectory + ".DigitalCatlog/ic_developmentworks.png";
      $scope.myimgs="file:///storage/sdcard0/.DigitalCatlog/ic_developmentworks.png";
    });

If I have pass the image path directly to img tag like following way, Image will show.

<img src="file:///storage/sdcard0/.DigitalCatlog/ic_developmentworks.png" />

Please suggest me what I did wrong or any other solution.


Solution

  • use

    <img data-ng-src="{{myimgs}}" />
    

    instead

    <img src="{{myimgs}}" />