My creativity has hit a roadblock and I'm looking for some help. I decided to use the Reactive Forms Module in Angular, so I imported it into my app.module.ts as shown below:
import { ReactiveFormsModule } from '@angular/forms';
@NgModule({
declarations: [
AppComponent,
...
],
imports: [
...
ReactiveFormsModule,
...
],
providers: [],
bootstrap: [AppComponent]
})
Within my Component, I defined the following:
import { Component, OnInit} from "@angular/core";
import { FormControl, FormGroup } from '@angular/forms';
@Component({
...
})
export class SearchComponent implements OnInit{
//Variables
form: FormGroup;
//Constructor
constructor(){}
//Methods
ngOnInit(){
this.form = new FormGroup({
'title': new FormControl(null)
});
}
showValue(){
console.log(this.form.get('title'));
}
}
Everything compiles without errors, but when trying to display it, the browser crashes with the following error in the Console: "core.js:6156 ERROR Error: NG0201: No provider for NgControl found in NodeInjector."
Any ideas on what might have gone wrong?
I would greatly appreciate any tips or suggestions.
Thank you!