【发布时间】:2017-09-26 15:13:23
【问题描述】:
我有一个模型,它是一个数组元素,它对应的 HTML 视图如下:
<div *ngIf="flag" >
<table id="table" class="table table-hover table-bordered table-mc-light-blue">
<thead>
<tr>
<th>col 1</th>
<th>col 2</th>
<th>col 3</th>
</tr>
</thead>
<tr *ngFor="let item of collection;">
<td>{{item.col1}}</td>
<td>
<input type="text" class="form-control" [(ngModel)]="item.col2" #input="ngModel" name="input-{{i}}">
</td>
</tr>
</table>
</div>
在某些情况下,我使用拼接插入新元素。请在下面找到代码
this.collection.splice(LastIndex, 0, ...newArray);
问题是在插入后,某些记录没有显示以前的 ngModel 值。 我检查了元素,发现 ng-reflect-model 设置为以前的值,但在输入控件中看不到值。
【问题讨论】:
-
问题对我来说似乎有点不清楚,你能不能尝试在一个 plunker 中重新创建这个问题,我很乐意看看 :)
标签: angular angular2-template angular2-directives