This form is where I craft my questions
https://i.sstatic.net/93781.png
When composing a question, the ability to include multiple alternatives is available. There will also be an option to edit these alternatives.
The desired format for my array is as follows:
{
"Question": "Question test",
"cod" : "pw3"
"Value" : "10"
"Alternatives": [
{
"test": "test",
"test2": "test",
"test3": "test"
},
]
}
Clicking on the add button allows for an unlimited number of alternatives to be added.
The code responsible for displaying the alternatives is shown below:
<table>
<thead><tr><th>Name</th><th>Action</th></tr>
</thead>
<tbody>
<tr *ngFor="let quiz of quizes">
<td>
<input name="alternativa" type="text" [(ngModel)]="quiz.pergunta" [disabled]="!quiz.isEditable"/>
</td>
<td>
<button (click)="quiz.isEditable=!quiz.isEditable" *ngIf="!quiz.isEditable">Edit</button>
<button *ngIf="quiz.isEditable" (click)="quiz.isEditable=!quiz.isEditable">Save</button>
</td>
</tr>
</tbody>
</table>
<div class="ui-g-2 ui-md-2 ui-lg-2 ui-fluid espacamento-baixo">
<p-button label="Salvar"></p-button>
</div>
I am seeking guidance on how to update the array when I click Save to finalize the question.