1

I am attempting to display an image on a view. I have a list of image names in the database and have the actual images stored in content/images. All that is showing up when I loop through is the alternate name and I only get that once. There should be 7 images or at the very least 7 alternate names being shown.

This is the code where I am attempting to show the images -

        <div class="row">
            <div ata-ng-repeat="route in vm.routes">
                <img data-ng-src="Content/images/{{route.department.imageNameLight}}.jpg" alt="test" />
            </div>
        </div>

I have looked a vm.routes and it does have the correct information. The image name is surrounded with quotes if that makes a difference? Eventually I will have a maximum of two rows of six images either show the light version of the image or the dark depending on a status flag.

1 Answer 1

1

Try this:

<div class="row">
    <div ata-ng-repeat="route in vm.routes">
        <img data-ng-src="{{'Content/images/' + route.department.imageNameLight + '.jpg'}}" alt="test" />
    </div>
</div>
Sign up to request clarification or add additional context in comments.

3 Comments

After a whole lot of trial and error I finally got it to work with span, but how do I split after 6 elements have been shown?
Depending on what your layout needs are, one option would be to add something like ng-style="{clear: $index % 6 == 0 ? 'left', 'none'}" to wrap it to the next line, or another option is to create your data as an array of arrays and then use two nested ng-repeats.
The first option would assume that all your divs had float: left

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.