I keep getting this error while using TypeScript\'s Angular2-forms framework:
There is no
directive
with \"exportAs\" set to \"ngForm
I had the same issue and solved it by updating all dependencies (package.json) with the following command npm update -D && npm update -S
As @Günter Zöchbauer pointed out, make sure to include the FormsModule first.
In my case I had to remove the ngNoForm
attribute from my <form>
tag.
If you you want to import FormsModule in your application but want to skip a specific form, you can use the ngNoForm directive which will prevent ngForm from being added to the form
Reference: https://www.techiediaries.com/angular-ngform-ngnoform-template-reference-variable/
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
BrowserModule,
FormsModule //<----------make sure you have added this.
],
....
})
You should terminate app with ctrl+c and re run it with ng serve, if you did not include FormsModule into you app.module file imports array, and then added it later, angular does not know it, it does not re-scan modules, you should restart app so angular could see that new module is included, after what it will included all features of template drive approach