1

Not similar to https://stackoverflow.com/questions/52235952/cannot-read-property-of-undefined-reactive-forms

StackBlitz - https://stackblitz.com/edit/github-rbjwcd-wtrevw

Having issues with the above demo. I am trying to get the form builder to work with models as per the example. The issue is with the .group property.

contactForm: FormGroup;

  createFormGroupWithBuilderAndModel(formBuilder: FormBuilder) {
    return this.formBuilder.group({
      personalData: formBuilder.group(new PersonalData()),
      requestType: '',
      text: ''
    });
  }

I think the issue might be not initialising the form on the return like:

this.contactForm = this.formBuilder.group

Can anybody get this to run?

Tom Rudge
  • 3,188
  • 8
  • 52
  • 94

1 Answers1

3

Fixing your stackblitz...

 constructor(private formBuilder: FormBuilder) {
    this.contactForm = this.createFormGroupWithBuilderAndModel(formBuilder);
  }
zerocewl
  • 11,401
  • 6
  • 27
  • 53