Can't bind to 'formGroup' since it isn't a known native property

Viewed 80

I have upgraded my application from Angular 2 to Angular 6 version. ng build --prod is building application successfully. I am able to login into my application and 50% functionality is working perfectly where some of the options are not working and throwing below exception:

EXCEPTION: Error: Uncaught (in promise): Template parse errors: Can't bind to 'formGroup' since it isn't a known native property (" <form class="form-inline" [ERROR ->][formGroup]="xSearchForm" (ngSubmit)="onSubmit()"> "): a@5:34

Can't bind to 'formControl' since it isn't a known native property ("abel> <input type="text" class="form-control pull-right" [(ngModel)]="model.xxx" [ERROR ->][formControl]="xSearchForm.find('yyy')" id="xxx" /> "): a@13:93

I am importing FormsModule and ReactiveFormsModule in app.module.ts and added these imports in NgModule imports also.

1 Answers

You need to import ReactiveFormsModule in your AppModule or in the module where your component is declared.

  import { FormsModule, ReactiveFormsModule } from '@angular/forms';

  ... 
  ...

  imports: [
    FormsModule,
    ReactiveFormsModule
  ]

ReactiveFormsModule is defined in @angular/forms

Related