Home > Back-end >  Angular 12 - Can't bind to 'ngModel' since it isn't a known property of 'in
Angular 12 - Can't bind to 'ngModel' since it isn't a known property of 'in

Time:03-08

This was asked years ago and I don't know if the answer has changed as I am on Angular 12. The answer seems to be two-fold and is caused but one of two scenarios. Either the app.module.ts does not have FormsControl in the imports section or there are multiple modules. I do have the FormsControl in my root file (app.module.ts) and I also only have one module. When I take the ngModel out of the input statement, it works fine. I am getting this using the tutorial enter image description here

app.module.ts

enter image description here

The parens instead of the brackets works much better. Thanks.

CodePudding user response:

You need to use [(ngModel)] instead of [{ngModel}] on the input tag

<input type="text" [(ngModel)]="DepartmentName" />
  • Related