title: AngularJS 1.5 - same as above address
body: <p>I want to implement a 'same as above' mailing address and permanent address. But then i tick on the checkbox, it does not show that the mailing address and permanent address are the same. help?   </p>
  
  <p><strong>controller</strong></p>
  
  <pre><code>$scope.candidateData.MailingAddress = {};
  
  $scope.$watch('mailingSameAsPermanent', function (value) {
      if (value) {
          $scope.candidateData.Address = $scope.candidateData.MailingAddress;
      } else {
          $scope.candidateData.Address = angular.copy($scope.candidateData.Address);
      }
  </code></pre>
  
  <p><strong>partial HTML:</strong></p>
  
  <pre><code>&lt;h3&gt;Permanent Address&lt;/h3&gt;
                      &lt;md-input-container class="md-block"&gt;
                          &lt;label&gt;Address&lt;/label&gt;
                          &lt;input name="add" ng-model="candidateData.Address.Address1"&gt;
                          &lt;div ng-messages="CandidateDetails.add.$error"&gt;
                              &lt;div ng-message="required"&gt;
                                  Please enter your address
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/md-input-container&gt;
  
                      &lt;md-input-container md-no-float class="md-block"&gt;
                          &lt;input ng-model="candidateData.Address.Address2" placeholder="Address 2"&gt;
                      &lt;/md-input-container&gt;
  
                      &lt;div layout-gt-sm="row"&gt;
  
  
                          &lt;md-input-container class="md-block" flex-gt-sm&gt;
                              &lt;label&gt;Country&lt;/label&gt;
                              &lt;md-select ng-model="candidateData.Address.Country"&gt;
                                  &lt;md-option&gt; &lt;!--ng-repeat="country in countries" value="{{country.Country}}"--&gt;&gt;
                                      {{candidateData.Address.Country}}
                                  &lt;/md-option&gt;
                              &lt;/md-select&gt;
                          &lt;/md-input-container&gt;
  
  
                          &lt;md-input-container class="md-block" flex-gt-sm&gt;
                              &lt;label&gt;Zip Code&lt;/label&gt;
                              &lt;input name="postalCode" ng-model="candidateData.Address.Zip" placeholder="12345"
                                     required ng-pattern="/^[0-9]{5}$/"&gt;
                              &lt;div ng-messages="CandidateDetails.postalCode.$error" role="alert" multiple&gt;
                                  &lt;div ng-message="required" class="my-message"&gt;You must supply a zip code.&lt;/div&gt;
                                  &lt;div ng-message="pattern" class="my-message"&gt;
                                      That doesn't look like a valid postal
                                      code.
                                  &lt;/div&gt;
  
                              &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;h3&gt;Mailing Address&lt;/h3&gt;
  
                      &lt;md-checkbox ng-model="mailingSameAsPermanent" &gt;
                          Tick if your mailing address is the same as your permanent address
                      &lt;/md-checkbox&gt;
                      &lt;div&gt;
                          &lt;md-input-container class="md-block"&gt;
                              &lt;label&gt;Address&lt;/label&gt;
                              &lt;input name="add" ng-model="candidateData.MailingAddress.Address1" ng-disabled="mailingSameAsPermanent"&gt;
                              &lt;div ng-messages="CandidateDetails.add.$error"&gt;
                                  &lt;div ng-message="required"&gt;
                                      Please enter your address
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/md-input-container&gt;
  
                          &lt;md-input-container md-no-float class="md-block"&gt;
                              &lt;input ng-model="candidateData.MailingAddress.Address2" placeholder="Address 2" ng-disabled="mailingSameAsPermanent"&gt;
                          &lt;/md-input-container&gt;
  
                          &lt;div layout-gt-sm="row"&gt;
  
  
                              &lt;md-input-container class="md-block" flex-gt-sm&gt;
                                  &lt;label&gt;Country&lt;/label&gt;
                                  &lt;md-select ng-model="candidateData.Address.Country"&gt;
                                      &lt;md-option&gt;
                                          &lt;!--ng-repeat="country in countries" value="{{country.Country}}"--&gt;&gt;
                                          {{candidateData.Address.Country}}
                                      &lt;/md-option&gt;
                                  &lt;/md-select&gt;
                              &lt;/md-input-container&gt;
  
  
                              &lt;md-input-container class="md-block" flex-gt-sm&gt;
                                  &lt;label&gt;Zip Code&lt;/label&gt;
                                  &lt;input name="postalCode" ng-model="candidateData.Address.Zip" placeholder="12345"
                                         required ng-pattern="/^[0-9]{5}$/"&gt;
                                  &lt;div ng-messages="CandidateDetails.postalCode.$error" role="alert" multiple&gt;
                                      &lt;div ng-message="required" class="my-message"&gt;You must supply a zip code.&lt;/div&gt;
                                      &lt;div ng-message="pattern" class="my-message"&gt;
                                          That doesn't look like a valid postal
                                          code.
                                      &lt;/div&gt;
  
                                  &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  </code></pre>