Adding new assets to ionic project


#1

I am new to ionic framework and trying out some samples.

I added a new .jpg under www–>img folder. When I run the project in a web browser using ionic serve command, I could see the .jpg rendering in the browser but when I run ionic emulate android command, the .jpg is not rendering, it seems to be broken.

Any idea how to resolve this.

thanks,
-dharma


#2

Hi dharma

You need to rebuild to project with

ionic build <platform>

regards

Patrick


#3

Hi Patrick,

I tried that but still t he .jpg is not rendering in the emulator.

Please find the attached screen shot.

thanks,
-dharma


#4

@dharma

A similar issue was discussed a while ago. Check it out: Images from image tag not loading in iOS emulator

Once you add the assets to your folder www/img be sure you include it in your project using this:

<img ng-src="img/picture.png" width="80">

Make sure there is no / before the src url. This fixed it for me.

Once you do this be sure to rebuild your app as @patrickdu mentioned. In your case substitute <platform> with android

Hope this helps.


#5

Hi dharma

Can you look in the folder /platforms/android/www if you can find the same asset.

regards

Patrrikc


#6

Hi @dharma,

please check -

may be you will get solution.


#7

@tjflamezz - thanks for your suggestion. That worked for me. I replaced src with ng-src and made sure there is no / before the ng-src url

thanks,
-dharma


#8

This fix doesn’t work for me!! [Android Lollipop]