在Ionic app中显示来自SD卡的图像

时间:2021-10-26 00:21:22

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

我想在我的Ionic应用程序中显示来自SD卡的图像,但是我有问题用img标签显示图像。

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标签,如下图所示,Image将显示。

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

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

请建议我做错了什么或任何其他解决方案。

1 个解决方案

#1


4  

use

使用

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

instead

代替

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

#1


4  

use

使用

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

instead

代替

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