Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.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
Javascript 无法显示来自json对象的图像_Javascript_Html_Angularjs_Json - Fatal编程技术网

Javascript 无法显示来自json对象的图像

Javascript 无法显示来自json对象的图像,javascript,html,angularjs,json,Javascript,Html,Angularjs,Json,我试图显示来自JSON对象的数据,我的对象如下图2所示 在数据中,我有c\u name,max\u slots和一个数组slots,在该数组中我有base\u image 我无法获取要在HTML中显示的基本图像数组 这是我当前的HTML打印输出 这是我的JavaScript $scope.GetData = function () { $http({ url: "http://www.ccuktech.co.uk/ccuploader/c

我试图显示来自JSON对象的数据,我的对象如下图2所示

在数据中,我有
c\u name
max\u slots
和一个数组
slots
,在该数组中我有
base\u image

我无法获取要在HTML中显示的基本图像数组

这是我当前的HTML打印输出

这是我的JavaScript

      $scope.GetData = function () {
        $http({
            url: "http://www.ccuktech.co.uk/ccuploader/campaigns/getCampaign",
            method: "POST",
            date: {},
            headers: {'Content-Type': 'application/json'}
        }).then(function (data) {
            // success
            console.log('you have received the data ');
            console.log(data);
            $scope.responseData = data.data;
        }, function (response) {
            // failed
            console.log('failed getting campaigns goo back to log in page.');
            console.log(response);
        });
     };

     $scope.GetData();
和HTML

<div ng-repeat="data in responseData">
  <h2>name</h2>:
  {{data.c_name}}

  <h2>max slots</h2>:
  {{data.max_slots}}

  <h2>image</h2>:
  {{data.base_image}}
</div>

姓名:
{{data.c_name}
最大插槽数:
{{data.max_slots}
图片:
{{data.base_image}

您不能仅在div标记中显示图像,请使用
由于
base\u图像
位于内部数组中,因此必须在
responseData的
ng repeat
中循环该数组

<div ng-repeat="data in responseData">
    <h2>name</h2>:
    {{data.c_name}}
    <h2>max slots</h2>:
    {{data.max_slots}}
    <h2>image</h2>:
     <img ng-src="{{data.base_image}}"></img>
 </div>

姓名:
{{data.c_name}
最大插槽数:
{{data.max_slots}
图片:
无法访问,因为它位于嵌套的
插槽
数组中,因此为了引用
基本图像
,您还必须遍历插槽。尝试下面给出的方法:


兄弟,我们现在正在尝试使用jade,所以只要转换,然后就会再次接受答案。谢谢你,伙计。
<div ng-repeat="data in responseData">
  <h2>name</h2>:
  {{data.c_name}}

  <h2>max slots</h2>:
  {{data.max_slots}}

  <h2>image</h2>:
  <div ng-repeat="slot in slots">
    <img src={slot.base_image} />
  </div>
</div>
{{data.base_image}}