Angular 如何在所有对象的数组中显示特定字段

Angular 如何在所有对象的数组中显示特定字段,angular,Angular,我是这样进入控制台的: article:Array 0:Object articleId: "WMCA880211" competingInterests: "ff" content: Array(3) 0: {title: "Abstract", content: "fdd", illustrations: Array(1)} 1: {title: "Introduction", content: "jj", illustrations: Array(1)} 2: {title: "Model

我是这样进入控制台的:

article:Array
0:Object
articleId: "WMCA880211"
competingInterests: "ff"
content: Array(3)
0: {title: "Abstract", content: "fdd", illustrations: Array(1)}
1: {title: "Introduction", content: "jj", illustrations: Array(1)}
2: {title: "Models", content: "kk", illustrations: Array(1)}
我想显示内容数组中所有对象的标题

我试过这样做,这里我使用双向数据绑定:

<div *ngFor="let article of latestarticles">
<div class="row" *ngFor="let Content of article.content">
<input class="form-control" id="usr" name="content" [(ngModel)]="Content.title">
</div>
</div>
我得到的是只输出的模型。我指的是内容数组的最后一个对象。
如何在内容数组中获取所有标题对象?

名称属性应该是唯一的

试试这个:

<div *ngFor="let article of latestarticles">
 <div class="row" *ngFor="let Content of article.content; let i = index">
  <input class="form-control" id="usr" [name]="'content_'+i" [(ngModel)]="Content.title">
 </div>
</div>

嗯,那么你的代码怎么了?我只从最后一个对象获得标题。我需要所有对象的标题你在之前的评论中检查过stackblitz吗?@DanilGudz,我想OP已经忘记了代码中的一个关键点,即这是一个表单!因此,OP,请始终记住包含所有有问题的必要代码,以查看您的问题是否得到了展示。最好的方法是在发布之前尝试代码,比如创建一个Stackblitz来看看你自己。因为你在这里展示的代码完全按照它应该的方式工作,但是当你添加表单标签时,它不会工作,因此下面的答案是正确的,即使回答者假设了这一点。顺便说一句,我也假设这是一个表单,因为我们不知道。。。