Angular 修复 - 无法绑定(bind)到 formGroup,因为它不是表单的已知属性

标签 angular angular-reactive-forms

我喜欢使用 Angular ReactiveFormsModule 创建一个表单。
构建应用程序时收到此错误消息:

Can't bind to 'formGroup' since it isn't a known property of 'form'
我已经用谷歌搜索了这个错误消息并找到了这些解决方案:
Can't bind to 'formGroup' since it isn't a known property of 'form'
Can't bind to 'formGroup' since it isn't a known property of 'form' in Angular 8
不幸的是,我无法用这个建议解决我的问题。
[编辑]
我用我的问题创建了一个最小的项目。请问有人可以看看吗?
https://github.com/Christoph1972/test-reactive-forms.git
我花了这么多时间才发现问题,显然我无法解决它......
[/编辑]
我的问题是什么?
恐怕解决方案会很简单,但我是 Angular 的新手。

最佳答案

你忘记在你的 app.module 中包含 TestModModule

import {TestModModule} from './test-mod/test-mod.module'
...
imports: [
    ...
    TestModModule
  ],
顺便说一句,您可以使用 *ngIf在您的表格中以避免缩写错误
<form *ngIf="myForm" [formGroup]="myForm">
   ...
</form>

关于Angular 修复 - 无法绑定(bind)到 formGroup,因为它不是表单的已知属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67282697/

相关文章:

Angular 4 - Reactive Forms - 从列表中未引用的对象中选择列表中的项目 - trackby 问题?

javascript - 在点击事件上动态添加新字段?

angular - 使用 ReactiveForms 和 NgbModal 时的 ExpressionChangedAfterItHasBeenCheckedError

javascript - 如果持续时间小于 1 小时或更长,如何添加条件 ngClass

mobile - 在网络应用程序 (Angular2) 和移动应用程序 (Ionic 2) 之间共享代码

angular - 如何在 Angular 2 中动态加载和显示包含 routerLink 指令的 html?

angular - 在 Angular Reactive Forms 中的 FormGroup 实例上设置错误无法按预期工作

angular - 惰性加载模块可以共享其父级提供的相同服务实例吗?

angular - 如何自定义 angular-cli 构建过程

angular - 如何在 Angular 的第一次更改时触发表单输入验证