Nesting Reactive Forms (Angular 5)

Multi tool use
I am trying to implement a nested form in Angular5. I want to divide the form into parent and many child components. I also want the submit event to be triggered differently for each individual child component.
I have attached the image as to how I want to create the form. Similar to address1, I want to create many child components with submit events carrying out different tasks.
How should I implement this form?
angular
add a comment |
I am trying to implement a nested form in Angular5. I want to divide the form into parent and many child components. I also want the submit event to be triggered differently for each individual child component.
I have attached the image as to how I want to create the form. Similar to address1, I want to create many child components with submit events carrying out different tasks.
How should I implement this form?
angular
What have you tried so far? Do you have any code to show us? Can you provide a stackblitz please.
– Zze
Nov 13 '18 at 20:57
Simply you could have he main form in a container and then pass it throughout the children as input parent like <mycomp-children [parent]="form">
– Whisher
Nov 13 '18 at 21:46
TemplateDriven or ReactiveForm ?
– Gilsdav
Nov 13 '18 at 23:10
Reactive Form @Gilsdav
– user10648256
Nov 14 '18 at 1:08
add a comment |
I am trying to implement a nested form in Angular5. I want to divide the form into parent and many child components. I also want the submit event to be triggered differently for each individual child component.
I have attached the image as to how I want to create the form. Similar to address1, I want to create many child components with submit events carrying out different tasks.
How should I implement this form?
angular
I am trying to implement a nested form in Angular5. I want to divide the form into parent and many child components. I also want the submit event to be triggered differently for each individual child component.
I have attached the image as to how I want to create the form. Similar to address1, I want to create many child components with submit events carrying out different tasks.
How should I implement this form?
angular
angular
edited Nov 13 '18 at 22:00


kboul
2,25521425
2,25521425
asked Nov 13 '18 at 20:52
user10648256user10648256
536
536
What have you tried so far? Do you have any code to show us? Can you provide a stackblitz please.
– Zze
Nov 13 '18 at 20:57
Simply you could have he main form in a container and then pass it throughout the children as input parent like <mycomp-children [parent]="form">
– Whisher
Nov 13 '18 at 21:46
TemplateDriven or ReactiveForm ?
– Gilsdav
Nov 13 '18 at 23:10
Reactive Form @Gilsdav
– user10648256
Nov 14 '18 at 1:08
add a comment |
What have you tried so far? Do you have any code to show us? Can you provide a stackblitz please.
– Zze
Nov 13 '18 at 20:57
Simply you could have he main form in a container and then pass it throughout the children as input parent like <mycomp-children [parent]="form">
– Whisher
Nov 13 '18 at 21:46
TemplateDriven or ReactiveForm ?
– Gilsdav
Nov 13 '18 at 23:10
Reactive Form @Gilsdav
– user10648256
Nov 14 '18 at 1:08
What have you tried so far? Do you have any code to show us? Can you provide a stackblitz please.
– Zze
Nov 13 '18 at 20:57
What have you tried so far? Do you have any code to show us? Can you provide a stackblitz please.
– Zze
Nov 13 '18 at 20:57
Simply you could have he main form in a container and then pass it throughout the children as input parent like <mycomp-children [parent]="form">
– Whisher
Nov 13 '18 at 21:46
Simply you could have he main form in a container and then pass it throughout the children as input parent like <mycomp-children [parent]="form">
– Whisher
Nov 13 '18 at 21:46
TemplateDriven or ReactiveForm ?
– Gilsdav
Nov 13 '18 at 23:10
TemplateDriven or ReactiveForm ?
– Gilsdav
Nov 13 '18 at 23:10
Reactive Form @Gilsdav
– user10648256
Nov 14 '18 at 1:08
Reactive Form @Gilsdav
– user10648256
Nov 14 '18 at 1:08
add a comment |
1 Answer
1
active
oldest
votes
First of all you need to know if you want to have a form with nested elements or need to create custom form controls.
In the first case, if you want to have a form with deep nesting of elements, you just need to follow the instructions on "Nested FormGroups" of the Angular documentation.
In the other case it is something more complex, and personally I think it is more oriented to your need. You must create a "Custom form control" which has its own logic and returns only the value produced by its interaction with it. Here is an example of how to implement it
Thank you. Using Nested FormGroups did work for me.
– user10648256
Nov 14 '18 at 6:05
Nice. I'm glad I helped you.
– Ricky
Nov 14 '18 at 13:36
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289335%2fnesting-reactive-forms-angular-5%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First of all you need to know if you want to have a form with nested elements or need to create custom form controls.
In the first case, if you want to have a form with deep nesting of elements, you just need to follow the instructions on "Nested FormGroups" of the Angular documentation.
In the other case it is something more complex, and personally I think it is more oriented to your need. You must create a "Custom form control" which has its own logic and returns only the value produced by its interaction with it. Here is an example of how to implement it
Thank you. Using Nested FormGroups did work for me.
– user10648256
Nov 14 '18 at 6:05
Nice. I'm glad I helped you.
– Ricky
Nov 14 '18 at 13:36
add a comment |
First of all you need to know if you want to have a form with nested elements or need to create custom form controls.
In the first case, if you want to have a form with deep nesting of elements, you just need to follow the instructions on "Nested FormGroups" of the Angular documentation.
In the other case it is something more complex, and personally I think it is more oriented to your need. You must create a "Custom form control" which has its own logic and returns only the value produced by its interaction with it. Here is an example of how to implement it
Thank you. Using Nested FormGroups did work for me.
– user10648256
Nov 14 '18 at 6:05
Nice. I'm glad I helped you.
– Ricky
Nov 14 '18 at 13:36
add a comment |
First of all you need to know if you want to have a form with nested elements or need to create custom form controls.
In the first case, if you want to have a form with deep nesting of elements, you just need to follow the instructions on "Nested FormGroups" of the Angular documentation.
In the other case it is something more complex, and personally I think it is more oriented to your need. You must create a "Custom form control" which has its own logic and returns only the value produced by its interaction with it. Here is an example of how to implement it
First of all you need to know if you want to have a form with nested elements or need to create custom form controls.
In the first case, if you want to have a form with deep nesting of elements, you just need to follow the instructions on "Nested FormGroups" of the Angular documentation.
In the other case it is something more complex, and personally I think it is more oriented to your need. You must create a "Custom form control" which has its own logic and returns only the value produced by its interaction with it. Here is an example of how to implement it
answered Nov 13 '18 at 21:11
RickyRicky
379421
379421
Thank you. Using Nested FormGroups did work for me.
– user10648256
Nov 14 '18 at 6:05
Nice. I'm glad I helped you.
– Ricky
Nov 14 '18 at 13:36
add a comment |
Thank you. Using Nested FormGroups did work for me.
– user10648256
Nov 14 '18 at 6:05
Nice. I'm glad I helped you.
– Ricky
Nov 14 '18 at 13:36
Thank you. Using Nested FormGroups did work for me.
– user10648256
Nov 14 '18 at 6:05
Thank you. Using Nested FormGroups did work for me.
– user10648256
Nov 14 '18 at 6:05
Nice. I'm glad I helped you.
– Ricky
Nov 14 '18 at 13:36
Nice. I'm glad I helped you.
– Ricky
Nov 14 '18 at 13:36
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289335%2fnesting-reactive-forms-angular-5%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
QI2VY,dqe421hm6
What have you tried so far? Do you have any code to show us? Can you provide a stackblitz please.
– Zze
Nov 13 '18 at 20:57
Simply you could have he main form in a container and then pass it throughout the children as input parent like <mycomp-children [parent]="form">
– Whisher
Nov 13 '18 at 21:46
TemplateDriven or ReactiveForm ?
– Gilsdav
Nov 13 '18 at 23:10
Reactive Form @Gilsdav
– user10648256
Nov 14 '18 at 1:08