How to reuse /share subforms or controls across multiple Reactive Forms in Angular

preview_player
Показать описание
Often we encounter a situation where multiple reactive forms share a subset of controls. There's no need to reinvent the wheel by creating multiple copies of the same controls for each form.
The solution is very easy.
1. Create a service that returns the shared form group.
2. Create a template that renders that shared portion.
3. Consume that template in as many reactive forms as you want.

The code are available at Github, though I don't think you need to access the code because they are so short and easy.
Рекомендации по теме
Комментарии
Автор

Great Help 🙌🏼. Thank You so much ❤️. This is the best video.

AmarSingh-uwdb
Автор

Hi Rui,

Thank you for providing this awesome solution. It saved a lot of effort

Regards
Mohammad

mohammadanas
Автор

But no reflection in shared form . where is your value updated ?

jayakumar
Автор

Good tutorial but will be happy if done with different component for better understanding.Thanks

brogidey
Автор

Hi, can I just put the parentform on the form element, so I don't need to pass parentGroup to the child?

chil
Автор

Became confusing as you named that form, Header

yafiecake
welcome to shbcf.ru