TypeScript-'s Angular Framework Error - "There is no directive with exportAs set to ngForm"
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
BrowserModule,
FormsModule //<----------make sure you have added this.
],
....
})
You have to import FormsModule
into not only the root AppModule, but also into every subModule that uses any angular forms directives.
// SubModule A
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
CommonModule,
FormsModule //<----------make sure you have added this.
],
....
})
I know this is a Old post, but i would like to share my solution. I have added "ReactiveFormsModule" in imports[] array to resolve this error
Error: There is no directive with "exportAs" set to "ngForm" ("
Fix:
module.ts
import {FormsModule, ReactiveFormsModule} from '@angular/forms'
imports: [
BrowserModule,
FormsModule ,
ReactiveFormsModule
],