问题描述
我正在尝试在Angular 2+中第二次单击时取消选中单选按钮在angularjs中完成.我有一个使用* ngFor显示的对象数组,因此我以一种形式具有多个单选按钮组.我需要一个可以取消选中该单选按钮的实现/我尝试过的所有实现都会不断检查和取消选中多个按钮,而其他实现则根本无法工作.
这是我当前的代码.如何使用打字稿在第二次单击时取消选中单选按钮?
您需要将单选值绑定到ngModel
,并监听ngModelChange
或click
事件而不是change
. >
此答案也可能对您有帮助 https://stackoverflow.com/a/42447116/4544288
>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?
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
这篇关于如何在第二次单击时取消选中单选按钮Angular 2+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!