How can I set up a reactive form in a service and then inject it into each component?
I have two components and a service. Both components share the same form as it is simply for typing in one component and displaying in the other.
// ---- Service Setup ----
public form: FormGroup;
constructor(
private formBuilder: RxFormBuilder
)
createform(sfm) {
this.form = this.formBuilder.formGroup(sfm);
}
// ---- Input and Output Components Setup ----
constructor(
private service: Service
) { }
ngOnInit() {
const sfm = new InputForm();
this.service.createform(sfm);
}
This results in an error stating that the form has not been initialized.