任何适用的指令或表单元素均未提供属性 formGroup (特别是 Angular CLI 13.0.4)

ojo*_*ifu 6 npm typescript angular-directive angular-cli angular

ReactiveFormsModule这不是导入或导入的问题FormsModule

我已经在 app.module.ts 和遇到此问题的模块中导入了这些内容:

  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    ReactiveFormsModule,
    ...
Run Code Online (Sandbox Code Playgroud)

所以当我将属性[formGroup]formControlName属性添加到.html file

<form  [formGroup]="loginForm" (ngSubmit)="doLogin()" class="m-t" role="form" action="index.html">
  <div class="form-group">
    <input type="email" class="form-control" formControlName="username" placeholder="Username" required="">
  </div>
  <div class="form-group">
    <input type="password" class="form-control" formControlName="password" placeholder="Password" required="">
  </div>
</form>
Run Code Online (Sandbox Code Playgroud)

我将 CLI 从 升级12.1.013.0.4

如果我降级到以前的版本,错误就会消失。

我已删除节点模块文件夹并重新运行npm install

由于此版本的 CLI 已于7 天前发布,因此我找不到此错误的任何解决方案。我还访问了Github 上的Angular cli 问题页面,但那里尚未提出任何问题。

如果有任何解决此问题的建议,我将不胜感激。降级不是一个选择。