Hi, I am building a new app.
I am showing form in the loop. On next, I reset the value of the current item, the value is reset but the checkbox is still showing previous value. Data for the checkbox is almost the same.
HTML code :
<ion-content *ngIf="!preview " >
<div style=“margin-top:5%;” text-wrap >
<ion-label *ngIf=“form && form.sections[sectionNo].title” stacked style=“padding-left: 10px;font-size:15px;” text-center>{{form.sections[sectionNo].title| uppercase}}</ion-label>
<ion-list radio-group *ngIf="form.sections[sectionNo].type=='select'" [(ngModel)]="form.sections[sectionNo].response" (ngModelChange) = "nextField()">
<ion-item *ngFor="let option of form.sections[sectionNo].data" >
<ion-label>{{option | uppercase}}</ion-label>
<ion-radio name="radio" [value]="option"></ion-radio>
</ion-item>
</ion-list>
</div>
</ion-content>
TS file :
nextField() {
if(this.form.sections[this.sectionNo].response){
this.saveData(this.form.sections[this.sectionNo].response, this.sectionNo);
if(this.sectionNo < this.maxSections){
this.sectionNo ++;
this.form.sections[this.sectionNo].response = “”;
}
else{
if(this.screen) this.submitForm();
else this.preview = true;
}
}
else alert(“Please Select Value”);
}
Sample Data Format :
“sections”: [
{
“filename”: “front”,
“required”: “true”,
“data”: [
“Intact”,
“Scratched”,
“Dented”,
“Missing”
],
“type”: “select”,
“title”: “Hub”,
“response”: null
},
{
“required”: “true”,
“data”: [
“Intact”,
“Scratched”,
“Dented”,
“Missing”
],
“filename”: “front”,
“type”: “select”,
“title”: “Handle”,
“response”: null
},
{
“required”: “true”,
“data”: [
“Intact”,
“Scratched”,
“Dented”,
“Missing”
],
“filename”: “front”,
“type”: “select”,
“title”: “Speedometer”,
“response”: null
},
{
“required”: “true”,
“data”: [
“Intact”,
“Scratched”,
“Dented”,
“Missing”
],
“filename”: “left”,
“type”: “select”,
“title”: “Left Cover”,
“response”: null
},
{
“required”: “true”,
“data”: [
“Intact”,
“Scratched”,
“Dented”,
“Missing”
],
“filename”: “right”,
“type”: “select”,
“title”: “Right Cover”,
“response”: null
}
]
Code is working and data is coming correctly but in the preview, checkbox shows previously selected value while the value is nul.
Please help