2015-04-16 197 views
1

我正在製作一個配置文件頁面,出於某種原因,我無法在其上加載靜態圖像。 這是我的找到函數,它查找路徑'/uploads/profilePic/image_name.jpg'中的圖像,其中此文件夾位於我的應用程序文件夾內。 路徑存儲,但圖像不顯示無法在角度模板中加載靜態圖像文件

$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; 
     }); 
    }; 

我的模板

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

ng-src應該是user.profileImage – harishr

回答

1

更改您的HTML這樣的:

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

你的NG-SRC需要平等:

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

另外,請確保您的圖像位於您的路徑指向的位置。

+0

我們如何確定路徑?我不斷得到http:// localhost:3000/uploads/profilePic/default.png 404(未找到)。我的上傳文件夾與應用程序位於同一目錄中 – jtand1

+0

這告訴我$ scope.user.profilePic的值是「default.png」。您必須在profilePic目錄中有一個名爲default.png的圖像才能運行。 – nweg

+0

我在該目錄中具有該名稱的圖像,但它不會加載 – jtand1

相關問題