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 嵌套数组迭代的角度7*Ng_Angularjs - Fatal编程技术网

Angularjs 嵌套数组迭代的角度7*Ng

Angularjs 嵌套数组迭代的角度7*Ng,angularjs,Angularjs,在Angular 7中,我有嵌套的对象数组,如下所示进行迭代。使用*ngFor的第一级迭代确实有效,但嵌套迭代不会显示任何值。有人帮我做什么吗?找到下面的代码 示例JSON const res=[{ 2: [ {id:1,cId:2,名称:'test1'},{id:2,cId:2,名称:'test2'} ], 8: [ {id:10,cId:8,名称:'test10'} ] }] {{country.key} {{airport.name} 使用以下内容更改html <div *ngF

在Angular 7中,我有嵌套的对象数组,如下所示进行迭代。使用*ngFor的第一级迭代确实有效,但嵌套迭代不会显示任何值。有人帮我做什么吗?找到下面的代码

示例JSON

const res=[{
2: [ 
{id:1,cId:2,名称:'test1'},{id:2,cId:2,名称:'test2'}
],
8: [ 
{id:10,cId:8,名称:'test10'}
]
}]
{{country.key}
{{airport.name}

使用以下内容更改html

<div *ngFor="let country of res[0] | keyvalue;">
   <span> {{country.key}} </span> <!-- Displayed 2 and 8 -->
   <div *ngFor="let airport of country.value">
         <span>{{airport.name}}</span> <!-- name should be displayed, but nothing is coming up-->
   </div>
</div>

{{country.key}
{{airport.name}
更具体地说,您必须用country.value替换country[country.key]

<div *ngFor="let country of res[0] | keyvalue;">
   <span> {{country.key}} </span> <!-- Displayed 2 and 8 -->
   <div *ngFor="let airport of country.value">
         <span>{{airport.name}}</span> <!-- name should be displayed, but nothing is coming up-->
   </div>
</div>