Image Path Ionic 2

Asked

Viewed 3,007 times

3

I’m new to Ionic, I come from native development with android and I’m a little lost in relation to the targeting of images in IONIC.

I’m creating on the home page, I call HOME, a menu with four options where the background of each option will be images.

In this way, I put the relative path (where the images are inside the /src/Assets folder) and run the $Ionic command, and it works normally in the browser. However, when I make $ Ionic run android, images do not appear on my smartphone or emulator.

I imagine this must be a load of crap, but for whoever starts it, it’s a lot of work. It’s been 24 hours since I researched, read content and can’t solve my problem.

What is the right place to place the images? How should I reference the path?

Thanks in advance!

1 answer

4

I found!!!

link -> https://stackoverflow.com/questions/39952214/correct-way-to-use-image-assets-in-ionic-2

Translating:

If you put the images inside www/img, they will only work locally through the $Ionic serves. To solve the problem using this form, you need to use Gulp to copy the images to the folder you want before build.

However, the previous form is obsolete. The recommended is to use the images within Assets/images and reference them with src="Assets/images/your-image.extension" This way it will work both locally and in emulators and Vices.

Browser other questions tagged

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