I'm currently working on implementing a modal, and I'm looking to link values from the formBuilder
to a specific property.
Here's the snippet of code I'm working with:
submit(data?: any) {
// THE FOLLOWING CODE WORKS, BUT IT'S NOT IDEAL IN TERMS OF QUALITY
this.contact.firstName = this.contactForm.value.firstName;
this.contact.firstName = this.contactForm.value.lastName;
this.contact.firstName = this.contactForm.value.Email;
this.contact.firstName = this.contactForm.value.PhoneNr;
// WHAT I WOULD PREFER TO DO (ALTHOUGH 'CONTACT' CONTAINS MORE FIELDS THAN 'CONTACTFORM')
// this.contact = this.contactForm.value;
this.onSubmit.emit(data);
}
The issue arises from the fact that the property contains more fields than the formBuilder
. Is there a method to map the common fields while retaining the additional fields in 'Contact'?