My scenario is as follows:
<input #physicalAddress1 type="text" formControlName="PhysicalAddressLine1" />
<tfg-toggle #physicalAsPostal
formControlName="PhysicalAsPostal"
[onText]="'Yes'"
[offText]="'No'"></tfg-toggle>
<input type="text"
formControlName="PostalAddressLine1"
[value]="physicalAsPostal.value === true ? physicalAddress1.value : ''" />
From the above code, a template reference variable
is assigned to 'PhysicalAddressLine1', and if 'PhysicalAsPostal' is selected (true), the value from 'PhysicalAddressLine1' should be copied into 'PostalAddressLine1' [value]
.
While this behavior works on the UI, the submitted form shows an empty value for 'PostalAddressLine1'.
This is how I retrieve values from the submitted form:
let provider: Provider = Object.assign({}, this.providerFormGroup.value);
console.log(provider.PostalAddressLine1); // Empty string: ""
I am unsure why this is happening. What can I do differently?