TJS UK TJS UK - 5 months ago 11
AngularJS Question

Dynamically showing images using AngularJS

I have a database with a list of items. Each item has it's own unique ID. I would like to associate the ID with an image in a folder using AngularJS. I have tried this:

<img ng-src="~/images/assets/mainImg/{{stages.stageID}}.gif" alt="{{imageDescription}}" style="width:100px;height:100px">


But it doesn't work. Any suggestions please?

Answer

Do you have a directory called ~ in your public path? You more than likely just want the define the source as below.

<img ng-src="images/assets/mainImg/{{stages.stageID}}.gif" alt="{{imageDescription}}" style="width:100px;height:100px">

If this doesn't work can you show us your directory structure?

Comments