I have an Angular2 application with a button that can add another loan to my loans. My * ngFor is also pretty simple:
<div *ngFor="let loan of myLoans">
<label>{{loan.name}}</label>
<input type="text" name="loan.name" [(ngModel)]="loan.amount">
</div>
myLoansis an array of Loan objects with nameand parameters amount. My button is also very simple.
<button id="addLoan" type="button" (click)="addLoan()">Legg til lån</button>
AddLoan () function:
addLoan(): void{
var newLoan = new Loan();
this.myLoans.push(newLoan);
}
My problem is that when I add a new loan to the list, any value that I had in the input field for my other loans returns to 0 or any value that I set in the constructor for the loan object.
Downloading the application shows this picture.

ngModel works when dialing a number

After pressing the “Legg til lån” button, the value of the first input is reset

ngModel is still working for the first input if I try to enter a different number

- , ?