I am using Angular reactive form and need to set the value of a Full Name
form control by using the values of First Name
and Last Name
. I have the code as follows :
<form [formGroup]="personForm">
<input type="text" formControlName="first_name" maxlength="255">
<input type="text" formControlName="last_name" maxlength="255">
<input type="text" formControlName="full_name" maxlength="255">
</form>
and the form is defined as :
this.personForm = this.formBuilder.group({
first_name: [_.get(person, 'first_name', ''),Validators.required],
last_name: [_.get(person, 'last_name', ''),Validators.required],
full_name: [_.get(person, 'display_name', ''),Validators.required]
});
I would like to generate the full_name
value as the combination of first_name
and last_name
when clicking on the full_name
input field. How can this be possible ?