gpt4 book ai didi

javascript - 模块 'FormBuilder' 导入了意外值 'AppModule'。请添加@NgModule 注解

转载 作者:行者123 更新时间:2023-11-30 08:18:59 25 4
gpt4 key购买 nike

如何在app.module中添加formbulder

由模块 AppModule 导入的意外值 FormBuilder。请添加@NgModule 注解。

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http";
import {FormBuilder, FormControl, FormGroup, Validators, FormsModule} from '@angular/forms';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { ClientComponent } from './client/client.component';
import { ClientTaskComponent } from './clienttask/clienttask.component';
import { ClientService } from './client/sherad/client.service';


@NgModule({
declarations: [
AppComponent, ClientComponent, ClientTaskComponent, ClientService
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
FormsModule,
FormBuilder,
FormGroup,
FormControl
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

最佳答案

import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http"; import {FormBuilder, FormControl, FormGroup, Validators, FormsModule} from '@angular/forms'; ........................///Remove this

import { FormsModule, ReactiveFormsModule } from "@angular/forms";..........//Add this

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { ClientComponent } from './client/client.component';
import { ClientTaskComponent } from './clienttask/clienttask.component';
import { ClientService } from './client/sherad/client.service';


@NgModule({
declarations: [
AppComponent, ClientComponent, ClientTaskComponent, ClientService
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
FormsModule,
FormBuilder,.........///Remove this
FormGroup,...........///Remove this
FormControl..........///Remove this
ReactiveFormsModule ..........//Add this
],
providers: [],
bootstrap: [AppComponent]
})

export class AppModule { }

并将其导入您的 .ts

import {FormBuilder, FormControl, FormGroup, Validators, FormsModule} from '@angular/forms';

永远记得在

@NgModule
(

声明仅包含组件

imports 仅包含modules

providers 仅包含services

关于javascript - 模块 'FormBuilder' 导入了意外值 'AppModule'。请添加@NgModule 注解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57156449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com