Image cannot be loaded in the application

Asked

Viewed 1,488 times

1

The image appears normal when running on "Ionic serves" but when I run on a device ionic run android --device it cannot be loaded, strange that I put an alt in the img tag and can only be displayed the alt, I tried to take but nothing appears.
My tag is like this :

<img src="../assets/img/logomarcaSaf.png" class="logo" (click)="infor()">

What could be causing bad image loading? I have another as background that is much heavier and appears normally.

1 answer

4


You must place the image straight from the Assets folder, if I remember correctly.

Try it this way:

<img src="/assets/img/logomarcaSaf.png" class="logo" (click)="infor()">

or so:

<img src="assets/img/logomarcaSaf.png" class="logo" (click)="infor()">

When Ionic compiles the app it plays to the build folder and the access is done by it, when using the .. / it loses the reference of the correct folder.

  • It worked, but I just didn’t understand the following, is that I have in the directory src/app/app.scss a 'background-image: url(../Assets/img/bgc2.png);" and works normally in both browser and device, this file is compiled in a different folder ?

  • Sorry friend but I don’t know how to answer you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.