Reactive form approach and setup
With this method angular is going to patch value to specific field without losing aother field’s data.
this.signupForm.form.patchValue({
userData: {
username: suggestedName
}
});
<button type="button" (click)="suggestUserName()">Suggest an Username </button>