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

Hello,
I’m having an error which I’m unable to get rid off since about half a day now.
I just created a form, and when adding [formGroup], an error keeps appearing: Can't bind to 'formGroup' since it isn't a known property of 'form'.

This is the first Ionic app I’m making so I’m showing you how my code is made here :

So, I created a components.module.ts in order to have access components because I don’t know why, my tags and other pages tags generated were not working. I had to make a global component which allows my app to get pages.

Inside my SurveyPage, I want my responses to change regarding a questions list so I created a component SurveyViewComponent.
On the form I have inside SurveyViewComponent I have this error Can't bind to 'formGroup' since it isn't a known property of 'form'.
Something I tried to fix this was to copy the form and put it inside its parent (SurveyPage) and no error happened.

Does someone know why I can’t access the property formGroup in my form tag inside my SurveyViewComponent ?

Thanks,
Best regards.

Hey! you need to import ReactiveFormsModule into your app.module.ts like this:
import { FormsModule, ReactiveFormsModule } from ‘@angular/forms’;
And then:@NgModule({
declarations: [AppComponent],
entryComponents: ,
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,
HttpClientModule, FormsModule, ReactiveFormsModule],
providers: [
StatusBar,
SplashScreen, IpService,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})

Hello,

Thanks for replying. I already tried that and I just tried again to make sure, but it doesn’t work
Both IDE (VSCode) and console show this error making my app unable to be displayed

For the first time, I’ve got the same problem but this solved mine. I use VSCode also. I can’t believe it doesn’t work. Try to type this command: npm install

Doesn’t work either.

But, it should be an issue with my global code because if I move all my form inside SurveyPage which is the parent of my SurveyViewComponent, the code works.
Seems like the child (SurveyViewComponent) can’t access modules of its parent

Hi, if you need help with forms in an ionic app, you can check this demo and get the code of the example app to see how to use reactive forms.

My form has been developed. It’s an issue with the import I think

Ok! I have one new problem! I develop an application to send sms for android.
On a single sim phone, it works fine. But on dual sim, I have set by default a sim wich I want use.
Something I want to is showing a prompt wich allows me to select sim card every time I send my message. Do have an idea about it, please? It’s troubling to set default sim every time

When you set up your SurveyViewComponent you have probably created some kind of Shared Module so that it can be included throughout the app, yes?

You need to import the FormsModule, ReactiveFormsModule in this module as well as the top level.

I do have a shared file but this is for components not for module.
I mean at the beginning. I was unable to use my new created components and pages tags inside my app.
I read in internet that I had to make a GlobalModule that would import and export my components in order to work.
Should I put the ReactiveFormsModules and FormsModule in imports and exports of this global file ?

Sorry guess I wasn’t thinking too clearly this morning :slight_smile:

Each page that has lazy loading support has its own module file, like in my screen shot below:

So you need to add the two imports into the (pagename).module.ts and then it should work.

I’ve already tried this way, I mean adding the modules’ imports inside my parent page’s module
But it’s child the component didn’t inherit them.
Might have forgotten something ? I mean perhaps declaring the component as its child or something else ? I don’t know what’s wrong here

EDIT :
I’ve created a new project at home and tried to make a quick retry.
Seems like it’s working.
My project at work seems to have a bad implementation globaly. Will try from a clean base tomorrow since project is commited on a local server, can’t get it now
I will keep your informed :slight_smile:

1 Like

I tried today from a new project and it worked.
Think that my first project’s “architecture” was bad.
Thank you, I just set your answer as solution ! :slight_smile:

1 Like