Join the Stack Overflow Community
Stack Overflow is a community of 6.3 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am trying to pass the image path to HTML page via angularJS controller in ASP.NET MVC project. The image stored in "contents/images" folder in the project. I am getting 404 (Not Found) Error. I am using IIS express. Below is the code

HTML

    <div class="carousel-inner" role="listbox" >
        <div data-ng-repeat="img in mainCtrl.images">
            <div class="item">
                <img src={{img.path}} alt={{img.name}} class="banner">
            </div>
        </div>
      </div>

Angular Controller

(function () {
    'use strict';

    angular
    .module('TestApp')
    .controller('mainCtrl', mainCtrl);

    mainCtrl.$inject = ['$scope'];

    function mainCtrl($scope) {
        $scope.images = 
            [
                { path: '..\Contents\images\banner\banner1.jpg', name:'banner1', item:"item active" },
                { path: '..\Contents\images\banner\banner2.jpg', name:'banner2', item:"item"},
                { path: '..\Contents\images\banner\banner3.jpg', name:'banner3', item:"item"}
            ]

    }

})();

It is trying to look for the images at http://testApp/Contents/images/banner/banner1.jpg

What is the correct way of passing the path of the image which is still going to work even after I published to IIS Server

-Alan-

share|improve this question
    
if you are using alias mainCtrl why you set the value on $scope, you should write: this.images = ..... – z0r0 Sep 8 '15 at 11:09

Does it work if you pass the base url as the path? Or maybe try replacing

<img src={{img.path}} alt={{img.name}} class="banner">

with

<img ng-src="{{img.path}}" alt="{{img.name}}" class="banner">

quick edit: sorry, I hadn't formatted the html a second ago.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.