Angular 7 - ngbRadioGroup 不工作 - 没有名称的表单控件的值访问器

Angular 7 - ngbRadioGroup not working - No value accessor for form control with name

我正在按照 NG-Bootstrap 的文档添加 ngbRadioGroup 组件,但我收到以下错误消息:错误:没有名称为表单控件的值访问器:'category'

实际上我已经从文档中粘贴了相同的代码,但我仍然遇到同样的问题。 我只按照 NG-Bootstrap 文档中的要求包括 bootstrap css(不是 js、jquery 和 popper)。

这是我正在使用的代码

myForm = new FormGroup({
  category: new FormControl('')
});
<div class="btn-group btn-group-toggle d-flex flex-column mt-4" ngbRadioGroup name="radioBasic" formControlName="category">
    <label *ngFor="let cat of categories" ngbButtonLabel class="btn btn-outline-primary mb-2">
        <input ngbButton type="radio" [value]="cat.id" /> {{cat.displayName}}
    </label>
</div>

这是 UI 的预期结果:

首先,请确保已导入 NgbModule

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

我假设你检查过这个:https://ng-bootstrap.github.io/#/components/buttons/examples。您可能想再次访问并查看 StackBlitz 上的示例以检查代码。