0

I have a parent form, and a child for within a main component. I am trying to get the main component to read the data from the parent form, but am getting an error: cyclic object value in the console.

My guess is that it is the parent form being defined in form-one and form-two, but I don't know how to do the following:

1) create a nested reactive form (form-two) that is shared with the parent form (form-one)
2) Allow the main component to access the form value of the parent and nested form.

My stackblitz example: https://stackblitz.com/edit/angular-dkddez

What am I doing wrong?

1 Answer 1

1

the error you're seeing is because you're applying the json pipe to a form group, which just isn't going to work because it has a recursive structure that can't be represented in string. apply it to the value:

{{formComponent.parentForm?.value | json }}

if you want all components to use the same form group, then make sure you're actually passing it to your sub component:

<app-form-two [parentForm]="parentForm"></app-form-two>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.