如何在第二次单击时取消选中单选按钮 Angular 2+ [英] How to uncheck a radio button on its second click Angular 2+

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

问题描述

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

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?

推荐答案

您需要将单选值绑定到 ngModel 并监听 ngModelChange>click 事件而不是 change.

You need to bind the radio value to an ngModel and either listen to the ngModelChange or click event instead of change.

这个答案也可能对您有所帮助https://stackoverflow.com/a/42447116/4544288

This answer might help you as well https://stackoverflow.com/a/42447116/4544288

这篇关于如何在第二次单击时取消选中单选按钮 Angular 2+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆