Reputation: 233
I have problem. When i want to add new row to table. It clears all previous rows.
This way i push new empty element.
testFunc()
{
//console.log(this.ProcessVATElems[this.elemIter].Lp);
this.ProcessVATElems[this.elemIter].Lp = ++this.elemIter;
var elem = new ProcessVatElement()
elem.Lp = 0;
this.ProcessVATElems.push(elem);
console.log(this.ProcessVATElems);
console.log(this.elemIter);
}
This is an example of my binding in html
<td>
<input type="text" class="form-control smallOpt" name="att23" [(ngModel)]="ProcessVATElems[index].NetValue"
[disabled]="End" id="Dom" placeholder="" style="width:50pt; height: 22pt; margin-left: 1pt;">
</td>
This is my table before adding new row.
And after ( I add new row by call testFunc() )
To add new row i click on table element where Lp == 0
<td (click)="testFunc()" >
{{elem.Lp}}
</td>
Upvotes: 0
Views: 95
Reputation: 21638
You need a unique name for each input
[name]="'att23_' + index"
Upvotes: 1