本文介绍了如何在第二次单击时取消选中单选按钮Angular 2+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Angular 2+中第二次单击时取消选中单选按钮在angularjs中完成.我有一个使用* ngFor显示的对象数组,因此我以一种形式具有多个单选按钮组.我需要一个可以取消选中该单选按钮的实现/我尝试过的所有实现都会不断检查和取消选中多个按钮,而其他实现则根本无法工作.

这是我当前的代码.如何使用打字稿在第二次单击时取消选中单选按钮?

解决方案

您需要将单选值绑定到ngModel,并监听ngModelChangeclick事件而不是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+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 01:31