【问题标题】:ngbRadioGroup fails to pre-select correct choicengbRadioGroup 未能预先选择正确的选择
【发布时间】:2020-10-21 21:05:36
【问题描述】:

我有 angular 8 字体结尾,我正在尝试发布 here 的无线电组控件,它在模板中有以下 ngbRadioGroup:

<div [(ngModel)]="model" ngbRadioGroup name="radioBasic">
  <label ngbButtonLabel class="btn-primary">
    <input ngbButton type="radio" [value]="1"> Left (pre-checked)
  </label>
  <label ngbButtonLabel class="btn-primary">
    <input ngbButton type="radio" value="middle"> Middle
  </label>
  <label ngbButtonLabel class="btn-primary">
    <input ngbButton type="radio" [value]="false"> Right
  </label>
</div>

在组件中,我有model = 1;,但是第一个选项没有预选(应该是),而是最后一个选项(最右边的单选按钮)是预选的(如下图),为什么?

经过多次试验,它似乎会在单选按钮的 [value] 评估为 false 时预先选择/突出显示。

【问题讨论】:

    标签: angular radio-group


    【解决方案1】:

    答案是为ngbRadioGroup div 定义唯一的“id”和“name”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-09
      相关资源
      最近更新 更多