Angular中出现的“errorNG8002:Can'tbindto'formGroup'sinceitisn'taknownpropertyof'form'.”
创始人
2024-10-31 01:00:26
0

在模块中导入“ReactiveFormsModule”模块,并在相关组件的模板中添加“formGroup”指令。示例如下:

app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    ReactiveFormsModule // 导入ReactiveFormsModule模块
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.ts:

import { Component } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  form: FormGroup;
  
  constructor(private fb: FormBuilder) {
    this.form = this.fb.group({
      // 定义表单项...
    });
  }
}

app.component.html:

相关内容

热门资讯

透视辅助!aapoker如何设... 透视辅助!aapoker如何设置胜率(透视)透视插件(本来是真的有挂);1、进入游戏-大厅左侧-新手...
透视中牌率!aapoker透视... 透视中牌率!aapoker透视方法(透视)透视脚本(切实是有挂);1、完成aapoker透视方法透视...
透视系统!aapoker脚本怎... 透视系统!aapoker脚本怎么用(透视)透视脚本下载(确实存在有挂)1、进入游戏-大厅左侧-新手福...
透视苹果版!aapoker如何... 透视苹果版!aapoker如何设置胜率(透视)透视软件(本来是真的有挂)1)aapoker如何设置胜...
透视有挂!aapoker怎么拿... 透视有挂!aapoker怎么拿好牌(透视)透视脚本下载(确实是真的有挂)1、操作简单,无需注册,只需...
透视存在!aapoker免费透... 透视存在!aapoker免费透视脚本(透视)透视插件(真是存在有挂)1、金币登录送、破产送、升级送、...
透视中牌率!aa poker透... 透视中牌率!aa poker透视软件(透视)万能辅助器(竟然是真的有挂);aa poker透视软件是...
透视攻略!aapoker透视怎... 透视攻略!aapoker透视怎么用(透视)透视脚本(本来有挂);1、上手简单,内置详细流程视频教学,...
透视辅助!aapoker真的假... 透视辅助!aapoker真的假的(透视)真的假的(总是有挂)1、每一步都需要思考,不同水平的挑战会更...
透视辅助!aapoker透视插... 透视辅助!aapoker透视插件(透视)插件(确实真的是有挂);1、操作简单,无需注册,只需要使用手...