I am new to angular. We are trying to build a big form using Angular Reactive forms
PFA stackblitz link for the example. I have a parent component person-form and its two child component person-job and person-info , containing few fields in each.
I am having two difficulties which I am not able to achieve .
1) I want user to completely fill the parent-form and then submit at the end .But if I fill info details first and then job details form and if I went back to info ; the details in info are not there . How to keep the filled details in the forms using Reactive forms approach. This happens on child form navigation.
2) Secondly, I want to combine both the forms result into a single json and send it to parent form component i.e person-form . How to achieve this. I am now able to get
{title: "XYZ", salary: "0000"}
// and
{name: "ABC", age: "12"}
But I want something like this :
{
combinedForm : {
info:{name: "ABC", age: "12"},
job:{title: "XYZ", salary: "0000"}
}
}
// OR
{
combinedForm : {
name: "ABC", age: "12",title: "XYZ", salary: "0000"
}
}
So that I can send or receive data from server easily and in one go.