如何在 ionic ngfor 中制作动态单选组按钮并将用户选择的内容传递给打字稿
how to make a dynamic radio-group button in ionic ngfor and pass to typescript what the user selected
API终点
http://questionaires.itresourcesgroup.com.au/public/networking
HTML
<form (ngSubmit)="submitNetworkingForm()">
<div *ngFor="let item of networkingdata;let i = index;" >
<ion-list *ngFor="let inner of item;let b = index;" radio-group [(ngModel)]="answers" name="answers" >
<ion-label>{{b}} . {{inner[i][b].question}}</ion-label>
<ion-item *ngFor="let innermost of inner[i];let c = index;">
<ion-label> {{innermost.answer}}</ion-label>
<ion-radio [value]="innermost.answer"></ion-radio>
</ion-item>
</ion-list>
</div>
<button ion-button type="submit">Submit</button>
</form>
我想让模型动态化。 php 中的类似内容:
echo '<input type="radio" name="salutation_description[]" value="'.$row1[0].'"/>'
然后传递给打字稿。
已删除
[(ngModel)]="answers" name="answers" 在此代码块中,它就像一个魅力
<ion-list *ngFor="let inner of item;let b = index;" radio-group [(ngModel)]="answers" name="answers" >
API终点
http://questionaires.itresourcesgroup.com.au/public/networking
HTML
<form (ngSubmit)="submitNetworkingForm()">
<div *ngFor="let item of networkingdata;let i = index;" >
<ion-list *ngFor="let inner of item;let b = index;" radio-group [(ngModel)]="answers" name="answers" >
<ion-label>{{b}} . {{inner[i][b].question}}</ion-label>
<ion-item *ngFor="let innermost of inner[i];let c = index;">
<ion-label> {{innermost.answer}}</ion-label>
<ion-radio [value]="innermost.answer"></ion-radio>
</ion-item>
</ion-list>
</div>
<button ion-button type="submit">Submit</button>
</form>
我想让模型动态化。 php 中的类似内容:
echo '<input type="radio" name="salutation_description[]" value="'.$row1[0].'"/>'
然后传递给打字稿。
已删除 [(ngModel)]="answers" name="answers" 在此代码块中,它就像一个魅力
<ion-list *ngFor="let inner of item;let b = index;" radio-group [(ngModel)]="answers" name="answers" >