如果我有一个localhost对象,如何在html中显示图像

时间:2017-06-19 13:32:00

标签: javascript html angularjs

该文件保存在localhost,我试图在我的客户端站点目录下载它,但我也没有得到任何解决方案。 这是我的对象

{link: "/home/company/S…1-eKdj#S0mkzO!3J__google-200x200.7714256da16f.png", name: "Courier", time: "2017-06-20 04:50:50.824948", $$hashKey: "object:3479"}

我尝试在我的localhost网址

之后附加链接

这是我的html img标签的src链接:

http://172.16.0.72:8134/pm/home/company/S%E2%80%A61-eKdj#S0mkzO!3J__google-200x200.7714256da16f.png

但仍未显示所需的图片..

2 个答案:

答案 0 :(得分:0)

如果对象在范围内,那么您可以这样做:

HTML

<img ng-src="{{image.link}}">

的JavaScript

$scope.image = {link: "/home/company/S…1-eKdj#S0mkzO!3J__google-200x200.7714256da16f.png", name: "Courier", time: "2017-06-20 04:50:50.824948", $$hashKey: "object:3479"};

工作代码:Plunkr

答案 1 :(得分:0)

尝试以下解决方案

&#13;
&#13;
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
    $scope.obj = {
      link: "https://www.w3schools.com/angular/pic_angular.jpg",
      name: "Courier",
      time: "2017-06-20 04:50:50.824948",
      $$hashKey: "object:3479"
    };
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
  <img ng-src="{{obj.link}}" alt="test">
</div>
&#13;
&#13;
&#13;

希望这对你有帮助