Attempting to insert a form within a *ngFor loop in order to replicate a button.
html file:
<div *ngFor="let passenger of passengerForm;let i=index;">
<form>
<mat-form-field>
<input matInput type="text" placeholder="Enter Name"
[(ngModel)]="passenger.Name">
</mat-form-field>
</Form>
<div>
<button (click)="addFieldValue(i); ">
Add Passenger
</button>
</div>
</div>
typescript file:
newAttribute ={}
addFieldValue(index) {
if ( index < 3) {
this.passengerForm.push(this.newAttribute )
this.newAttribute = {};
}
}