How to uncheck a radio button on its second click Angular 2+

感情迁移 提交于 2019-12-25 19:56:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!