Angular 4 - 将json数据显示为表时出错

时间:2017-12-03 11:34:57

标签: json angular typescript

使用Angular 4,Typescript我无法显示以下json的内容:

  1. timed_out,文本框中的max_score
  2. 表中的CV / JOB。

    任何提示

      

    {“take”:56,“timed_out”:false,“_ shards”:{       “总数”:18,       “成功”:18,       “失败”:0},“点击”:{       “总计”:23381243,       “max_score”:2.2639267,       “点击”:[         {           “_index”:“2018-09”,           “_type”:“ABC”,           “_id”:“122”,           “_score”:2.2639267,           “fields”:{             “简历”: [               “过程”             ]             “工作”:[               “PAP”             ]           }         },         {           “_index”:“2018-09”,           “_type”:“ABC”,           “_id”:“123”,           “_score”:2.2639267,           “fields”:{             “简历”: [               “富”             ]             “工作”:[               “BNN”             ]           }         }       ]}}

1 个答案:

答案 0 :(得分:0)

您需要嵌套 ngFor

 <tr *ngFor="let dataobj of data.hits.hits">
   <td  *ngFor="let jobObj of dataobj.fields.JOB">               
      {{jobObj}}      
   </td >
   <td  *ngFor="let hitobj of dataobj.fields.CV">               
     {{hitobj}}      
    </td >            
</tr>

<强> STACKBLITZ DEMO