Can't bind to 'formControl' since it isn't a known property of 'input' - Angular2 Material Autocomplete issue Can't bind to 'formControl' since it isn't a known property of 'input' - Angular2 Material Autocomplete issue angular angular

Can't bind to 'formControl' since it isn't a known property of 'input' - Angular2 Material Autocomplete issue


While using formControl, you have to import ReactiveFormsModule to your imports array.

Example:

import {FormsModule, ReactiveFormsModule} from '@angular/forms';@NgModule({  imports: [    BrowserModule,    FormsModule,    ReactiveFormsModule,    MaterialModule,  ],  ...})export class AppModule {}


Forget trying to decipher the example .ts - as others have said it is often incomplete.

Instead just click on the 'pop-out' icon circled here and you'll get a fully working StackBlitz example.

enter image description here

You can quickly confirm the required modules:

enter image description here

Comment out any instances of ReactiveFormsModule, and sure enough you'll get the error:

Template parse errors:Can't bind to 'formControl' since it isn't a known property of 'input'. 


Another reason this can happen:

The component you are using formControl in is not declared in a module that imports the ReactiveFormsModule.

So check the module that declares the component that throws this error.