1

I am making a profile page and for some reason I can't load a static image on it. Here is my find function which looks for the image in the path '/uploads/profilePic/image_name.jpg' where this folder is inside my app folder. The path is stored but the image doesn't display

$scope.find = function(){
        $http.get('/profile/'+$stateParams.username).success(function(user){
            $scope.user = user;
            $scope.user.profileImage = '/uploads/profilePic/'+user.profilePic;
            console.log($scope);
        }).error(function(response){
            $scope.error = response.message;
        });
    };

My template

<img ng-src="{{profileImage}}" alt="temp" class="img-thumbnail"><hr>
1
  • ng-src should be user.profileImage Commented Apr 16, 2015 at 3:51

1 Answer 1

1

Change your html to this:

<img ng-src="{{user.profileImage}}" alt="temp" class="img-thumbnail"><hr>

Your ng-src need to equal:

ng-src="{{user.profileImage}}"

Also, make sure your image is located where your path is pointing.

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

9 Comments

how do we determine the path ? i keep getting localhost:3000/uploads/profilePic/default.png 404 (Not Found). My upload folder is in the same directory as the app
That tells me the value of $scope.user.profilePic is "default.png". You would have to have an image named default.png located in profilePic directory for this to work.
I have an image with that name in that directory but it doesn't load
If that's the case you should be able to just type that image url into your browser and it will pull up. If it doesn't pull up then your path is wrong. Angular isn't the problem at this point.
Is the image a png or jpg? In your question to reference a jpg image in your initial paragraph.
|

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.