NG0201: No provider for NgControl found in NodeInjector

I was trying to use the Reactive forms in my Nativescript-Angular Project, and i am getting the following error.

JS: Error: NG0201: No provider for NgControl found in NodeInjector
JS:     at new ZoneAwareError (file: node_modules\@nativescript\zone-js\zone-nativescript.js:1298:0)
JS:     at new RuntimeError (file: node_modules\@angular\core\__ivy_ngcc__\fesm2015\core.js:1303:0)
JS:     at throwProviderNotFoundError (file: node_modules\@angular\core\__ivy_ngcc__\fesm2015\core.js:1369:0)
JS:     at notFoundValueOrThrow (file: node_modules\@angular\core\__ivy_ngcc__\fesm2015\core.js:3271:0)
JS:     at lookupTokenUsingModuleInjector (file: node_modules\@angular\core\__ivy_ngcc__\fesm2015\core.js:3306:0)
JS:     at getOrCreateInjectable (file: node_modules\@angular\core\__ivy_ngcc__\fesm2015\core.js:3408:0)
JS:     at Module.ɵɵdirectiveInject (file: node_modules\@angular\core\__ivy_ngcc__\fesm2015\core.js:14428:0)
JS:     at NodeInjectorFactory.NgControlStatus_Factory [as factory] (file: node_modules\@angular\forms\__ivy_ngcc__\fesm2015\forms.js:1240:119)

Answer

In order to use the  Reactive forms, we need to import FormsModule in app.module.ts as well as in local module file

import { FormsModule } from '@angular/forms';
@NgModule({
...  
imports: [
    ...
   FormsModule
  ],
  ...
})

 

Add comment