【问题标题】:ngModel binding to radio button in angular2ngModel绑定到angular2中的单选按钮
【发布时间】:2017-08-20 17:10:44
【问题描述】:

Non Rule Based 的值为“n”,Rule based 的值为“R”。 根据这个值,我需要在 UI 中动态选择单选按钮值。

在 ts。

this.vGroup = this.arr.vzGroup; // the value of vGroup is either "R" or "N"

我需要在 UI 中创建一个带有选项“规则”和“非规则”的单选按钮,并且应该选择选项。 有人可以在这里帮忙。

这是我试过的

<input type="radio" name="optradio" [checked]=" *ngIf="vzGroup=='R'" ? 'true' : 'false' ">
    <input type="radio" name="optradio" [checked]=" *ngIf="vzGroup=='N'" ? 'true' : 'false' ">

【问题讨论】:

  • 帮助来了,在路上……
  • 那么你有什么尝试,向我们展示你的模板,你正在尝试这样做......
  • 类似这样的东西,截至目前,我正在将值打印在文本中,但是对于单选按钮选项,我尝试过这样..

标签: angular typescript radio-button dynamically-generated


【解决方案1】:

也许这就是你要找的-

<input type="radio" name="rule" [checked]="vGroup=='R'">
<input type="radio" name="rule" [checked]="vGroup=='N'">

【讨论】:

  • @WebDev 这是你要找的吗?
猜你喜欢
  • 2015-10-31
  • 2014-03-24
  • 2016-06-09
  • 2017-03-02
  • 2017-11-07
  • 2016-11-07
  • 2011-10-06
  • 2016-10-21
  • 1970-01-01
相关资源
最近更新 更多