我是新手,尝试过堆栈溢出建议的所有可能方法,但到目前为止没有成功。 FormGroup没有绑定。我已经在app.module.ts和* .component.ts中添加了ReactiveFormsModule。我一直在使用Angular 8.x
详细信息:
Package Version
-----------------------------------------------------------
@angular/animations 8.2.7
@angular/cdk 8.2.0
@angular/cli 8.3.4
@angular/forms 8.2.7
@angular/http 7.2.15
@angular/material 8.2.0
@angular/router 8.2.7
@ngtools/webpack 8.3.4
@schematics/angular 8.3.4
@schematics/update 0.803.4
rxjs 6.4.0
typescript 3.5.3
webpack 4.39.2
=====================
<div class="container">
<div class="row">
<div class="profile">
<form [FormGroup]="catCreate" class="example-form">
=====================================
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl, ReactiveFormsModule } from '@angular/forms';
@Component({
templateUrl: './create-category.component.html', ...
})
export class CreateCategoryComponent implements OnInit {
catCreate: FormGroup; ...
===============================
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CreateCategoryComponent } from './components/create-category/create-category.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MaterialsModule } from './material-module';
@NgModule({
declarations: [
AppComponent,
UploaderComponent,
CreateCategoryComponent
],
imports: [
MaterialsModule,
FormsModule,
ReactiveFormsModule,
.......
Error: Compiler.js:2175 Uncaught Error: Template parse errors:
Can't bind to 'FormGroup' since it isn't a known property of 'form'. ("a">
<form [ERROR ->][FormGroup]="catCreate" class="example-form">
ng:///AppModule/CreateCategoryComponent.html@8:30
答案 0 :(得分:1)
您需要用小写的驼峰字母绑定它:[formGroup]而不是[FormGroup]。