I need assistance with passing form inputs into a typescript file as an array in an ionic application.
The form is located in question.page.html
<details *ngFor="let product of products;">
<ion-input type="text" [(ngModel)]="productId" value="{{product.id}}"></ion-input>
<h2>Question</h2>
<ion-input type="text" [(ngModel)]="question"></ion-input>
<h2>Contact Back</h2>
<ion-select [(ngModel)]="contactBack" interface="popover">
<ion-select-option value="0">No</ion-select-option>
<ion-select-option value="1">Yes</ion-select-option>
</ion-select>
</details>
<ion-button type="button" (click)="sendQuestion()">Send Question</ion-button>
I am looking to display the result in a typescript file (question.page.ts) similar to the structure below:
"productQuestions": [
{
//First
'productId': 'value',
'question': 'value',
'contactBack': 'value',
},
{
//Second
'productId': 'value',
'question': 'value',
'contactBack': 'value',
},
...
],
I am familiar with handling forms that have unique fields, but I am uncertain about how to approach forms with repeated inputs. Any guidance would be greatly appreciated.
Thank you in advance.