我有一个要显示的值集。这是它的结构。我遇到的问题是尝试显示第三项,因为它的结构略有不同。请注意,这可以是动态的,因此它并不总是具有不同结构的第三项。
[
{
"id": "1b255d6d-f771-4c16-9d64-fdb188dc9298",
"categoryId": null,
"filename": "dummy.pdf",
"url": "http..."
},
{
"id": "8d17ee10-54e0-48eb-8c21-83e7c6ca6751",
"categoryId": null,
"filename": "dummy (1).pdf",
"url": "http..."
},
[
{
"id": "42b30baf-a945-412e-a53d-803e57c684cf",
"categoryId": null,
"filename": "1 Rules of the Road draft1.pdf",
"url": "http..."
}
],
{
"id": "1d0531e0-f0ad-4026-bfa0-5f19fa4fbca0",
"categoryId": null,
"filename": "offer.pdf",
"url": "http..."
}
]
这是我的 HTML
<div *ngIf="candidateDocuments" class="ui-g-12 ui-md-12 ">
<div *ngFor="let doc of candidateDocuments" class="ui-g-6 ui-sm-12">
<div class="doc-container">
<span
><img src="img"
/></span>
<span>{{ doc.filename }}{{ doc.filetype }}</span>
<button (click)="openDocWindow(doc.url)">...</button>
</div>
</div>
</div>
我尝试了以下方法,但它不起作用
<div *ngIf="candidateDocuments" class="ui-g-12 ui-md-12 ">
<div *ngFor="let doc of candidateDocuments; let i = index" class="ui-g-6 ui-sm-12">
<div class="doc-container">
<span
><img src="img"
/></span>
<span>{{ doc.filename }}{{ doc.filetype }}</span>
<button (click)="openDocWindow(doc.url)">...</button>
<div *ngFor="let userdoc of doc.Array" class="ui-g-6 ui-sm-12">
<div class="doc-container">
<span
><img src="img"
/></span>
<span>{{ userdoc.filename }}{{ userdoc.filetype }}</span>
<button (click)="openDocWindow(userdoc.url)">...</button>
</div>
</div>
</div>
</div>
</div>