如何首先检查默认单选按钮。单击上一个按钮,然后选中上一个选定值单选按钮。
<input type="radio" name="Answer" [(ngModel)]="Answer" [value]="Test[i].ans1" (change)="selected(Test[i].ans1)" formControlName="Answer"> :{{Test[i].ans1}}<br />
<input type="radio" name="Answer" [(ngModel)]="Answer" [value]="Test[i].ans2" (change)="selected(Test[i].ans2)" formControlName="Answer"> :{{Test[i].ans2}}<br />
<input type="radio" name="Answer" [(ngModel)]="Answer" [value]="Test[i].ans3" (change)="selected(Test[i].ans3)" formControlName="Answer"> :{{Test[i].ans3}} <br />
<input type="radio" name="Answer" [(ngModel)]="Answer" [value]="Test[i].ans4" (change)="selected(Test[i].ans4)" formControlName="Answer"> :{{Test[i].ans4}}<br />
</div>
<button (click)="Prevoius($event)" class="btn btn-primary">Previous</button>
<button type="button" [disabled]="radioTest.controls['Answer'].invalid" (click)="Next($event)" class="btn btn-primary">Next</button>
</form>
答案 0 :(得分:1)
你可以这样做
<input type="radio" name="Answer" [(ngModel)]="Answer" [value]="Test[i].ans1" (change)="selected(Test[i].ans1)" [checked] =“!Answer” formControlName="Answer"> :{{Test[i].ans1}}<br />
使用[checked]可以勾选复选框