jtand1
jtand1

Reputation: 11

Can't load static image file in angular template

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>

Upvotes: 1

Views: 2626

Answers (1)

nweg
nweg

Reputation: 2865

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.

Upvotes: 1

Related Questions