【问题标题】:how deselect radio-button in angular 6? [duplicate]如何在角度 6 中取消选择单选按钮? [复制]
【发布时间】:2019-11-17 02:06:53
【问题描述】:

当单选按钮被选中时,我无法取消选择。我该怎么办?!

<div>
    <label id="sim-type-label">type of sim</label>
    <mat-radio-group formControlName="simType"
                     aria-labelledby="sim-type-label">
    <mat-radio-button value="false">Type1</mat-radio-button>
    <mat-radio-button value="true">Type2</mat-radio-button>
    </mat-radio-group>
</div>

我有两个单选按钮。如果我选择一个单选按钮,则无法取消选择它,我希望单击选择并再次单击取消选择。但如何?!在默认情况下不起作用的角度 6 中!请帮忙。谢谢。

【问题讨论】:

  • 嗨,欢迎来到堆栈溢出。 documentation 页面呢?还附上了一个 StackBlitz 示例。
  • 你想要的是 CheckBox 的特性,但是你可以通过(点击)事件来实现你想要的特性
  • @hadi 如何通过(点击)事件实现我想要的功能?!给我解决方案:))
  • 检查thisQA

标签: javascript html angular angular6


【解决方案1】:

单选按钮的功能是从组中选择至少一个,并根据您的要求,其复选框的功能是选择和取消选择。

【讨论】:

  • 我希望该用户能够选择“type1”或“type2”之一,或者一个都不选。 @Manpreet
猜你喜欢
  • 2020-05-28
  • 2019-08-08
  • 2021-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-01
  • 2012-02-21
  • 2019-01-17
相关资源
最近更新 更多