0

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?

2
  • Is your base href set properly in .NET? This is as much a .Net question as an angular question (probably more). Inspect the image in the browser and see what the path is resolving to. Commented Jun 6, 2016 at 15:16
  • can you check the error ? what is the path it is actually set when rendered? Commented Jun 6, 2016 at 15:18

1 Answer 1

3

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?

Sign up to request clarification or add additional context in comments.

1 Comment

Actually, mine does work. {{stages.stageID}} should've been {{stageID}}. Been coding too long today! Thanks for your correct answer! If it helps the ~/ refers to the root directory of the project, easier than using many ../

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.