Solution :
I had faced this issue while writing my first code in Angular App. The solution is easy just follow below procedure.
Lets assume that you are creating the new NgModule, say some AuthModule
which is dedicated towards handling all your Auth needs, then you must import FormsModule
in your AuthModule too.
If you want to use the FormsModule
only in your AuthModule
then you dont need to import your FormModule
in your default AppModule
So write below code in your AuthModule
:
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { authRouting } from './auth.routing';
import { LoginComponent, SignupComponent } from './auth.component';
@NgModule({
imports: [
authRouting,
FormsModule
],
declarations: [
SignupComponent,
LoginComponent
]
})
export class AuthModule { }
Then just forget about the importing in the AppModule
if you don't want to use your FormsModule
anywhere else.
If you want to use the two-way data binding for the form inputs then you need to import your FormsModule
package in the Angular
module.