+-

我刚刚更新到angular 9!突然得到这个异常。Error occurs in the template of *, error NG8003: No directive found with exportAs 'ngForm'
这里是模板。
<form (ngSubmit)="onLogin(frm.value)" #frm="ngForm" style="margin:0 auto;"> //All of these was working fine before the update
我也导入了 FormsModule, ReactiveFormsModule, CommonModule 在 app.module.ts:
imports: [
BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }),
HttpClientModule,
FormsModule,
ReactiveFormsModule,
CommonModule,
注意,我使用的是Visual Studio angular模板。
谢谢你的帮助。
1
投票
投票
你必须添加 ngForm 指令的形式。
<form (ngSubmit)="onLogin(frm.value)" ngForm #frm style="margin:0 auto;">