2
I’m starting with Angular 2 and I have a question, I believe simple, in the creation of forms:
For example in a system that contains the following entries:
- Customers
- Suppliers
- Carriers
Each registration will have its respective fields and will also have shared fields as for example the address fields. For this I could create a Component and use it in the respective forms? What would be the sending of these forms to the class objects using Reactive Form? This is the right thing to do, or should I recreate the address fields in each form?
I haven’t used Reactiveforms yet, but usually if you have fields or a portion of code that will be replicated constantly is already a strong indication that componentization can be applied, in your address case, I think it applies very well a standard Component to treat address.
– Gabriel Berlanda
Okay, I’m still a little confused about sending the form data to the class Typescript, whether to create several Forms to be sent by the click event or a single form containing the Component <app-address> for example.
– Eriel Miquilino
You can create an <app-address> with a @Output by returning an Emit to the parent typescript ... from a look at @Output()
– Herbert Junior
@Gabrielberlanda I think this might help you data pass this link has an example where you share data between components I think this can help you.
– Ivan Antunes