To implement this functionality, you can use the code snippet below (make sure to include validation as well, but here is a basic working example https://stackblitz.com/edit/angular-p3cztw):
HTML Code:
<div *ngFor="let item of formDataList; let i = index;">
<form>
<input type="text" [(ngModel)]="item.detail" name="detail" />
<input type="text" [(ngModel)]="item.amount" name="amount" />
<input type="date" [(ngModel)]="item.date" name="date" />
<button (click)="removeItem(item)"> remove </button>
</form>
</div>
<form #addForm="ngForm">
<input type="text" [(ngModel)]="data.detail" name="detail" />
<input type="text" [(ngModel)]="data.amount" name="amount" />
<input type="date" [(ngModel)]="data.date" name="date" />
<br/>
<button (click)="addItem(data)"> add </button>
</form>
TypeScript Code:
public data = {};
public formDataList = [];
addItem($item) {
this.formDataList.push($item);
this.data = {};
}
removeItem($item) {
this.formDataList.splice(this.formDataList.indexOf($item), 1);
}