【发布时间】:2016-08-10 06:33:06
【问题描述】:
我正在使用 angular2,在我的表单中,我通常创建一个模型类并将我的对象与表单绑定,然后通过 this.myObject 访问。
<div class="form-group ">
<label class="col-md-3 control-label">Label</label>
<div class="col-md-6">
<input type="text" class="form-control" [(ngModel)]="diplome.label" name="label">
</div>
</div>
稍后获取我的数据
private diplome = new Diplome();
let myData = this.diplome;
当我使用*ngFor 显示数据数组时,我现在处于一个位置,我希望在单击提交时将所有这些数据作为特定类的数组。
...
<tr *ngFor="let inscription of inscriptions">
<td>
<span *ngIf="inscription._etudiant">{{ inscription._etudiant.label }}</span>
</td>
<td>
<div class="form-group ">
<div class="col-md-6">
<input type="number" class="form-control" name="note">
</div>
</div>
</td>
</tr>
...
我希望能够在每次迭代中使用绑定将数据插入到输入中的铭文对象。
【问题讨论】:
-
你想从哪里得到它?
-
在我的 component.ts 中触发提交点击按钮后。
标签: angular