Angular 13 表单模块与安装的表单模块相关的错误

发布于 2025-01-10 22:01:55 字数 1875 浏览 2 评论 0原文

注意:

Error: src/app/money_makers/shochat_guts/shochat_content_creator_components/active-stream-dashboard/shochat-contentcreator-chat/shochat-contentcreator-chat.component.html:81:18 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.

81                  [(ngModel)]="forminput"

但是看看我的应用程序模块,

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

    imports: [
    FormsModule,
    ....
    ]

此错误仅在我将 Angular 10 项目迁移到 Angular 13 项目时发生。

我通过启动一个新的 Angular 13 项目,然后将 src 文件夹移动到新的 Angular 13 项目,然后安装所有依赖项来完成此迁移,

为什么会发生这种情况?

@NgModule({
  declarations: [
    ...
    
    ShochatContentcreatorChatComponent,

    ShochatDisplayToUserComponentComponent,
    ShochatUserChatComponent,
    UserSetChatnameComponent,
    ShochatUserLivevideoComponent,
    ShochatUserShochatsDisplayComponent,
    ShochatUserVideoCallComponent,
    ShochatVideoChatComponent,
    ShochatUserVideoCallActualComponent,
    ShochattimerComponent,
    UserconsomablepreviewComponent,
    CreditcardorloginaddneeedComponent,
    ContentcreatorendshochatreviewComponent,
    UserendshochatreviewComponent,
    UserFavLikesPurchaesesComponent,
    CreatorstatsComponent,
    CreatortypeindexComponent,
    ShochatshowpreviewComponent,
    EmailverifedrefreshuserloginComponent,
    ContentfeedpostsComponent,
    ContentcreatorintrovideodashboardComponent,
    ShochatEncodingHowtoComponent,
    SubscribingplaceholderComponent,
    ContentcreatorcategoriesadminComponent,
    ModeratecreatorpostsadminComponent,
    ContentfeedpostcommentsComponent,
  ],
    imports: [
      CommonModule,
      BrowserModule,
      RouterModule,
      FontAwesomeModule,
      RecaptchaV3Module,
      FormsModule,
      ReactiveFormsModule,
      HttpClientModule,
      AppRoutingModule,

notice:

Error: src/app/money_makers/shochat_guts/shochat_content_creator_components/active-stream-dashboard/shochat-contentcreator-chat/shochat-contentcreator-chat.component.html:81:18 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.

81                  [(ngModel)]="forminput"

but look at my app module

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

    imports: [
    FormsModule,
    ....
    ]

this error only happened when I migrated my angular 10 project to a angular 13 project.

I did this migration by starting a new angular 13 project and then moving over the src folder to the new angular 13 project and then installed all dependencies

why is this happening?

@NgModule({
  declarations: [
    ...
    
    ShochatContentcreatorChatComponent,

    ShochatDisplayToUserComponentComponent,
    ShochatUserChatComponent,
    UserSetChatnameComponent,
    ShochatUserLivevideoComponent,
    ShochatUserShochatsDisplayComponent,
    ShochatUserVideoCallComponent,
    ShochatVideoChatComponent,
    ShochatUserVideoCallActualComponent,
    ShochattimerComponent,
    UserconsomablepreviewComponent,
    CreditcardorloginaddneeedComponent,
    ContentcreatorendshochatreviewComponent,
    UserendshochatreviewComponent,
    UserFavLikesPurchaesesComponent,
    CreatorstatsComponent,
    CreatortypeindexComponent,
    ShochatshowpreviewComponent,
    EmailverifedrefreshuserloginComponent,
    ContentfeedpostsComponent,
    ContentcreatorintrovideodashboardComponent,
    ShochatEncodingHowtoComponent,
    SubscribingplaceholderComponent,
    ContentcreatorcategoriesadminComponent,
    ModeratecreatorpostsadminComponent,
    ContentfeedpostcommentsComponent,
  ],
    imports: [
      CommonModule,
      BrowserModule,
      RouterModule,
      FontAwesomeModule,
      RecaptchaV3Module,
      FormsModule,
      ReactiveFormsModule,
      HttpClientModule,
      AppRoutingModule,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瀟灑尐姊 2025-01-17 22:01:55

确保您还在功能模块中导入 FormsModule ,该模块包含您正在使用 ngModel 的组件。

@NgModule({
  imports: [FormsModule], 
  declarations:[ShowChatComponent] 
})
export class ShowChatModule {}

Make sure you also import the FormsModule in the feature module which holds the component where you are using the ngModel.

@NgModule({
  imports: [FormsModule], 
  declarations:[ShowChatComponent] 
})
export class ShowChatModule {}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文