I have a requirement to add a field dynamically in my Ionic 4 app. I have declared an array variable in my ts file.
fields: [];
When I press the button I want to generate a new field with inputs fields. This is my code on the view:
<ion-grid>
<ion-row *ngFor="let field of fields">
<ion-col>
<ion-input></ion-input>
</ion-col>
<ion-col>
<ion-input></ion-input>
</ion-col>
</ion-row>
</ion-grid>
This is my code for the button:
<ion-button expand="full" (click)="addField()">Add field</ion-button>
How can I add a row dynamically when I press the button?