Developer Snippet Diary

Can't bind to 'ngModel' since it isn't a known property of 'input'

To fix this error, you need to import the FormsModule in your app module:

 

Also, import your component in App Module.

Make sure you have imported the BrowserModule or CommonModule in your app module

===========

<!-- Correct -->
<input type="text" name="username" [(ngModel)]="username">

<!-- Incorrect -->
<input type="text" name="username" ng-model="username">

 

Posted by: Muhammad Farhan
Email: helpinghour@gmail.com