Can't bind to 'formGroup' since it isn't a known property of 'form'错误解决方案

项目中运用的是 angular-material,用form的时候报错
Can't bind to 'formGroup' since it isn't a known property of 'form'

解决方案:

需要从 @angular/forms 导入ReactiveFormsModule。因为FormGroupDirective 指令属于 ReactiveFormsModule 一部分。

app.module.ts中:

import { FormsModule, ReactiveFormsModule } from '@angular/forms';

imports: [
    ……
    FormsModule,
    ReactiveFormsModule,
    ……
  ],

你可能感兴趣的:(Can't bind to 'formGroup' since it isn't a known property of 'form'错误解决方案)