简体   繁体   中英

Can't bind to 'formGroup' in angular 7?

I know this may be duplicate question of " Can't bind to 'formGroup' since it isn't a known property of 'form' "

I found solution that i have to import { REACTIVE_FORM_DIRECTIVES } from '@angular/forms' .

But where can i add this reactive form?

Now i'm working in applyjob.component.html i think i have to add reative form directives in applyjob.component.ts but its not working.

The answer will be appreciated!

formGroup , formControl , etc are all directives that are exposed as a part of the ReactiveFormsModule . If you want to use these directives in a Component, you'll have to either import the ReactiveFormsModule in the Module that this Component is registered in. Or you'll have to export the ReactiveFormsModule from some other module( SharedModule for instance) and then import that module in the module that you have this Component registered in.

Did you add this?:

import { ReactiveFormsModule } from '@angular/forms';
...
@NgModule({
  ...,
  declarations: [..., ApplyJobComponent, ...]
  imports: [..., ReactiveFormsModule, ...],
  ...
})
export class YourModule {...}
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM