Hi
my app can’t retrive files over the internet. I am debugging it using
ionic run android -lcs
I get this error:
An error on the XMLHttpRequest:NetworkError---Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://boardlineapp.com/app/images/pros/gatiendelahaye.png'.
638 819639 log http.readyState=4 for url=http://boardlineapp.com/app/images/pros/gatiendelahaye.png
639 819647 log http.status=0 for url=http://boardlineapp.com/app/images/pros/gatiendelahaye.png
I am using the whitelist plugin, but I’ve got no <meta http-equiv=“Content-Security-Policy” in my index.html head.
I have the following in my config.xml:
If the files you are checking will all be images, I recommend this directive:
Instead of you manually writing a service to check if the image exists or not, you can just specify either a fall-back image (‘ng-error-src’) or a fall-back function call (‘ng-error’).
In my app, I do this for profile images. If the profile image doesn’t exist, I just display a default profile image. Works great!
You will see errors in the console such as
GET (your image url) 404 (Not Found), but you can either ignore those or just filter them out of the console. I’m sure you could write an interceptor but thats basically what this directive is doing for you.
If the files aren’t just images, I’m sure you could tweak that directive to get it to work as well.
Yes but the app updates the database file which refers to a lot of files. So I test every reference in the db file to know whether or not the file is locally avail or remotely only.
If you set ng-src to a function call that checks your 2 locations for the image and returns undefined if you can’t find it, I believe the ng-error-src will take over. If it doesn’t for undefined, give it a bad url you know doesn’t exist so it fires the error.