ankit singh
ankit singh

Reputation: 1

Failed: Template parse errors: Can't bind to 'ngModel' since it isn't a known property of 'input'. (" <div class="input-group">*

After updating to angular 12 , i am getting below error.

project is building and running , but whenever i am trying ng test for unit testing , i am getting below errors

Failed: Template parse errors: Can't bind to 'ngModel' since it isn't a known property of 'input'. ("

i tried importing import { FormsModule, ReactiveFormsModule } from '@angular/forms'; but still same error . please help me on this.

Upvotes: 0

Views: 490

Answers (1)

Dorin Baba
Dorin Baba

Reputation: 1728

You have to import those modules into your module where the current component is located via adding a reference to then into imports array.

@NgModule({
  ...
  imports: [
    BrowserModule,
    FormsModule, <====
    ReactiveFormsModule <====
  ],
  ...
});

Recompile the project, it should work now. Note that just adding the import this way: import { FormsModule, ReactiveFormsModule } from '@angular/forms' won't solve your problem because the module does not know about them, therefore FormsModule and ReactiveFormsModule won't be inserted into your bundle after compilation.

Upvotes: 0

Related Questions