There is a checkbox available for selecting the billing address to be the same as the mailing address. If the checkbox is checked, both values will remain the same, even if one of them is changed. Currently, I have successfully achieved copying the mailing address to the billing address once the box is checked. However, if the values are altered afterwards, the view does not update accordingly. Below is the code snippet that represents what has been implemented so far:
createcustomer.html:
<section class="mainbar" data-ng-controller="createcustomer as vm">
<div class="col-md-4">
<label for="txtMailingAddress1">Address 1:</label>
</div>
<div class="col-md-8">
<input type="text" id="txtMailingAddress1" name="txtMailingAddress1" value="" data-ng-model="vm.MailingAddress1" class="form-control FloatLeft" required />
</div>
<input type="checkbox" id="checkboxSameAddress" data-ng-model="vm.IsBillingMailing" data-ng-change="vm.copyMailingAddress()" />Check if billing address same as mailing address
<div class="form-group">
<div class="col-md-4">
<label for="txtBillingAddress1">Address 1:</label>
</div>
<div class="col-md-8">
<input type="text" id="txtBillingAddress1" name="txtBillingAddress1" data-ng-model="vm.BillingAddress1" class="form-control FloatLeft" required />
</div>
</div>
</section>
createcustomer.js
function copyMailingAddress() {
if (vm.IsBillingMailing) {
vm.BillingAddress1 = vm.MailingAddress1;
}
else {
vm.BillingAddress1 = '';
}
}