ngbRadioGroup无法预先选择正确的选择

问题描述

我的字体为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;,但是没有预先选择第一个选项(应该是),而是预先选择了最后一个选项(最右边的单选按钮)(如下所示) ,为什么?

enter image description here

经过更多试验后,似乎单选按钮的[value]评估为false时,它将预选择/突出显示

解决方法

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