I am creating a form in Angular 2. My goal is to get data from the API and pass it into the form for editing purposes. However, I am running into this error:
Guys who face issues with reactive forms First in your component.ts file make sure you import the following:
import { FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
export class NewsfeedformComponent implements OnInit {
NewsfeedForm: FormGroup;
constructor(private _formBuilder: FormBuilder){}
ngOnInit() {
this.lookupService.getStatus().subscribe((status: IStatus) => {
this.status = status;
});
this.NewsfeedForm = this._formBuilder.group({
NewsfeedID: [0,null],
StatusID: ['', Validators.required],
publishdate: ['', Validators.required]
})
}
}
in your component html file