Angular 13在安装表单模块时出现与表单模块相关的错误



注意:

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文件夹移到新的angle 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,

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

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

最新更新