0

Even though I imported FormsModule, ReactiveFormsModule in app.module.ts always I get No provider for NgControl found in NodeInjector. error

home.page.html

<ion-content style="max-height: 160px;">
  <form [formGroup]="todo" (ngSubmit)="logForm()">
    <ion-item>
      <ion-label>Todo</ion-label>
      <ion-input type="text" formControlName="title"></ion-input>
    </ion-item>
    <ion-item>
      <ion-label>Description</ion-label>
      <ion-textarea formControlName="description"></ion-textarea>
    </ion-item>
    <button ion-button type="submit" [disabled]="!todo.valid">Submit</button>
  </form>
</ion-content>

app.module.ts

@NgModule({
....
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, FormsModule, ReactiveFormsModule],
...

What may be the reason behind this?

devnc
  • 70
  • 7
  • 2
    add `ReactiveFormsModule ` in homepage modules file – Ravi Ashara Mar 17 '21 at 04:47
  • @RaviAshara it solved the issue. Thnx. – devnc Mar 17 '21 at 05:55
  • Does this answer your question? [Getting No provider for NgControl Error after adding ReactiveFormsModule to my angular 4 app](https://stackoverflow.com/questions/48525216/getting-no-provider-for-ngcontrol-error-after-adding-reactiveformsmodule-to-my-a) – Ramesh Rajendran Mar 17 '21 at 07:01
  • @RameshRajendran No, that's what I did first. I've already mentioned that I added `ReactiveFormsModule` in app.module.ts – devnc Mar 17 '21 at 07:23

1 Answers1

0

Make sure to add ReactiveFormsModule in home.page.module.ts file

Kavinda Senarathne
  • 1,813
  • 13
  • 15