Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Can';t在角度模板中加载静态图像文件_Angularjs - Fatal编程技术网

Angularjs Can';t在角度模板中加载静态图像文件

Angularjs Can';t在角度模板中加载静态图像文件,angularjs,Angularjs,我正在制作一个个人资料页面,由于某些原因,我无法在上面加载静态图像。 这是我的查找函数,它在路径“/uploads/profilePic/image_name.jpg”中查找图像,该文件夹位于我的应用程序文件夹中。 路径已存储,但图像不显示 $scope.find = function(){ $http.get('/profile/'+$stateParams.username).success(function(user){ $scope.user =

我正在制作一个个人资料页面,由于某些原因,我无法在上面加载静态图像。 这是我的查找函数,它在路径“/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>


将您的html更改为:

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

此外,请确保图像位于路径指向的位置

我们如何确定路径?我一直得到404(未找到)。我的上载文件夹与告诉我$scope.user.profilePic的值为“default.png”的应用程序位于同一目录中。您必须在profilePic目录中有一个名为default.png的图像才能工作。我在该目录中有一个名为default.png的图像,但它不会加载。如果是这种情况,您应该能够在浏览器中键入该图像url,然后它就会拉起来。如果它不拉起,那么你的路径是错误的。角度不是问题所在。图像是png还是jpg?在您的问题中,在初始段落中引用jpg图像。ng-src应为user.profileImage
ng-src="{{user.profileImage}}"