i ran completly out of ideas. I want to user Reactive Forms Module, so i imported it in app.module.ts like
import { ReactiveFormsModule } from '@angular/forms';
@NgModule({
declarations: [
AppComponent,
...
],
imports: [
...
ReactiveFormsModule,
...
],
providers: [],
bootstrap: [AppComponent]
})
In my Component i defined:
import { Component, OnInit} from "@angular/core";
import { FormControl, FormGroup } from '@angular/forms';
@Component({
...
})
export class SearchComponent implements OnInit{
//Variablen
form: FormGroup;
//Konstruktor
constructor(){}
//Methoden
ngOnInit(){
this.form = new FormGroup({
'title': new FormControl(null)
});
}
showValue(){
console.log(this.form.get('title'));
}
}
Compiling works well, but when displaying it it crashes with the error below shown in the Browser Console:
"core.js:6156 ERROR Error: NG0201: No provider for NgControl found in NodeInjector."
Does anybody of you has an idea what went wrong?
I would really appreciate any hint.
Thanks a lot!
question from:
https://stackoverflow.com/questions/65936059/error-error-ng0201-no-provider-for-ngcontrol-found-in-nodeinjector 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…