angularangular-directivengmodel

ng model is not working even after importing forms module in app.module.ts file?


Here is the attached screenshot where you can see that FormsModule is imported in app.module.ts file but still the error haven't resolved

enter image description here

[![enter image description here][2]][2]

Here is the login component and screenshot is posted given below [2]: https://i.sstatic.net/Lcfq4.png

Any help would be appreciated and thanks in advance


Solution

  • Open app.module.ts and add the import line

    import { FormsModule } from '@angular/forms';
    

    And add FormsModule to imports

    @NgModule({
      imports: [
        FormsModule
      ],
    })
    

    And i could see that you have forgot to declare your LoginComponent!

    @NgModule({
      declarations: [
        LoginComponent
      ],
    })