4

I tried a nested form controls using formarray and it's updating the form value, if i change the existing display values. However I tried to add a form group in formarray, the content is appearing in the UI and not if form value (JSON). I have posted the code in stackblitz. Thanks in advance.

https://stackblitz.com/edit/angular-nested-forms-reactive-vvczmt

1 Answer 1

4

In your html, if you use <pre> {{ form.getRawValue() | json }} </pre> instead of <pre> {{ form.value | json }} </pre> you will see the full object.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks. Can you let me know why it works for edit and not for new value, if possible.
personally I don't know why, at least not in your case. I think the .value is meant to be data that is set up to be seen (there are flags like .disable() which will hide things in value even though you can see it in the form, and emitEvent: false which will prolong when value is updated) but .getRawValue() will show the most up to date data for all values no matter what flags are set.
Angular documentation mentions that the value property is the way to get the value of the group because it excludes disabled controls in the FormGroup. getRawValue() retrives all values regardless of their disabled status. Ref: angular.io/api/forms/FormGroup#getrawvalue
@balaG - In new mode, there might not be any control which is disabled, and hence it works for new.

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.