Angularjs 嵌套数组迭代的角度7*Ng
在Angular 7中,我有嵌套的对象数组,如下所示进行迭代。使用*ngFor的第一级迭代确实有效,但嵌套迭代不会显示任何值。有人帮我做什么吗?找到下面的代码 示例JSONAngularjs 嵌套数组迭代的角度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
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>