Skip to main content

Posts

Showing posts with the label Standalone Components

Solved: 'Can't bind to ngModel' in Angular Standalone Components

  You have just migrated an existing component to "Standalone" mode, or perhaps you are spinning up a fresh component in Angular 17+. You add a simple input field, bind it with   [(ngModel)] , and your application crashes. The console throws the infamous error: Can't bind to 'ngModel' since it isn't a known property of 'input'. This error is the most common friction point for developers adopting the Standalone Component architecture. It occurs because the mental model for dependency management has shifted from implicit (Module-based) to explicit (Component-based). Here is the immediate technical solution, followed by the architectural root cause and edge cases regarding  ReactiveFormsModule  and  CommonModule . The Immediate Fix To resolve this error, you must explicitly import  FormsModule  into the  imports  array of your standalone component's metadata. In the legacy  NgModule  architecture, you likely imported  FormsModule ...