I'm working on a MCQ in Angular 6. I have a problem with my checkboxs which show the good answer straight away because of this line: [(ngModel)]="answer.good". But the problem is that without this line i can't determine if the answers are good or bad.
answer.component.html :
<div class="" *ngFor="let answer of answers">
<div class="answer">
<label class="container">
<input type="checkbox"
[(ngModel)]="answer.good" />
{{answer.text}}
<span class="checkmark"></span>
</label>
</div>
</div>
Does someone has a solution to keep the record of the answers of the user but hide the good answer in the same time ?
Try changing the input as
<input type="checkbox" [ngModel]="answer.good" (ngModelChange)="checkGood($event)" />
and in the ts
checkGood(good){
if(good){
// do what you want with good
}
}