问题
I am trying to implement Radio button uncheck on second click in Angular 2+ as done here in angularjs. I have an array of objects that get displayed using *ngFor, therefore I have multiple radio button groups in one form. I need an implementation that will onlt uncheck the said radio button/ All the implementations I have tried keep checking and unchecking multiple buttons while other implementations don't work at all.
This is my current code right now. How can I implement Radio button uncheck on second click using typescript?
回答1:
You need to bind the radio value to an ngModel
and either listen to the ngModelChange
or click
event instead of change
.
This answer might help you as well https://stackoverflow.com/a/42447116/4544288
来源:https://stackoverflow.com/questions/55005641/how-to-uncheck-a-radio-button-on-its-second-click-angular-2