<form name="check-boxes">
<div *ngFor="let quest of noOfQuestions">
<div class="form-check form-check-inline" *ngFor="let ans of noOfAnswers">
<label class="form-check-label">{{ans}}
<input class="form-check-input" type="checkbox" name="{{quest}}" id="{{quest}}{{type}}" value="{{ans}}" (change)="getAnswers(id)">
<span class="form-check-sign"></span>
</label>
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
此代码根据提供的 noOfQuestions 和 noOfAnswers 生成一组复选框。我想在选中复选框时将复选框的特定 id 传递给函数“getAnswer”。ts 文件中传递的参数“id”值表示未定义。getAnswer() 的参数应该是什么来传递所选复选框的 id ???