Image Path Ionic 2

3

I'm new to Ionic, I come from native development with android and I'm a bit lost in pointing out images at IONIC.

I'm creating in the home page, which 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 squeeze the $ ionic serve, and it works normally in the browser. However, when I do $ ionic run android, the images do not appear on my smartphone or emulator.

I suppose this must be a hell of a lot of bullshit, but it's hard work for those starting out. I have been researching, reading content for 24 hours and I can not solve my problem.

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

Thank you in advance!

    
asked by anonymous 05.04.2017 / 18:53

1 answer

4

I found it !!!

link - > link

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 the build.

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

    
05.04.2017 / 22:19