My current reactive form setup looks like this:
this.editform = new FormGroup({
'username' : new FormControl(null,[Validators.required]),
'password' : new FormControl(null,[Validators.required]),
'full_name' : new FormControl(null,[Validators.required]),
'avatar' : new FormControl(null,[Validators.required]),
});
When I use the onSubmit() function, I encounter an issue where changing the submitValue variable also alters the value in the editForm. Here is a snippet of my code:
onSubmit() {
const submitValue = this.editform.value
submitValue.username = 'Jon';
console.log(this.editform.value.username) // Output : 'Jon' [The value of editform also changed]
}
I specifically want to get the form value from the editForm and handle it separately in the submitValue variable without affecting the original form values. Is there a solution to achieve this separation?