Inserting image into ionic2 dynamically


#1

I am trying to add png files to my applications. However, keep getting 404 error content not found. By this time, I have tried many ways but none successful;

If I use the following, I only get “?” mark instead of an image and 404 error.

<img [src]="'assets/img/measure-img/' +'question.image'"/>

They have to be inserted dynamically, therefore, in html and not scss file.

Anyone having the same issue?


#2

See working example in my repo

https://github.com/aggarwalankush/ionic2-mosum/blob/master/src/pages/template/weather-list.template.html#L27-L28

https://github.com/aggarwalankush/ionic2-mosum/blob/master/src/pages/providers/util.service.ts#L113-L119

and image in assets folder

https://github.com/aggarwalankush/ionic2-mosum/blob/master/src/assets/img/sunrise.png


#3

Many thanks! Made it work.


#4

Any more examples somewhere? Having a similar issue :). Thanks


#5

@kierandes Updated links below

and images in assets folder