简体   繁体   中英

Displaying image from device storage in Ionic App

I have image file on device in Android/data/myApp folder called test.jpg. I want to display it in img tag. I've tried every possible path in src attribute but nothing works. I've also tried change src to ng-src or data-ng-src. Nothing works and I am getting desperate.

The image is visible in storage when I look through windows explorer but it doesn't in my app. If I use $cordovaFile.checkFile function, everything looks perfect in the result data. File exists, has nativeURL but still doesn't show in the view.

Anyone had this problem? I've read everything google has to offer in this topic, but still without any progress on this issue. Can someone show me some simple example how to retrive image in Ionic app from device storage? What path should look like? Maybe I have to add some permissions to my config.xml or andorid manifest? It's my first hybrid App. I don't have much experience in AngularJS/Cordova/Ionic.

I've really stuck. Please help.

Ok, so I guess I have to answer this question myself. Everything works fine now when I use nativeURL of the file as src. I've added img-src: *; to the content of http-equiv="Content-Security-Policy" meta tag in index but it still didn't work. After 10th time restarting app suddenly everything was fine. I still don't know if this was problem with meta tag but it work now so I am happy.

If anyone want to see my config.xml, manifest or index just ask.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM