<h4 class="bg-primary">Change Email</h4>

<p><strong>Current Email:</strong> {{user.email}} </p>

<form name="chgEmailForm" novalidate>
  <div class="form-group">
      <input class="form-control" type="password" name="password" placeholder="Enter password" ng-minlength="8" ng-model="formData.password" ng-pattern="/^(?:[0-9]+[a-z]|[a-z]+[0-9])[a-z0-9`\-=\\\[\];',\./~!@#\$%\^&\*\(\)_\+|\{\}:<>\?]*$/i" required>
      <p class="help-block" ng-show="chgEmailForm.password.$dirty && chgEmailForm.password.$error.required">This field is required.</p>

  </div>

  <div class="form-group">
      <input class="form-control" type="email" name="newEmail" placeholder="New email" ng-model="formData.newEmail" required>

      <p class="help-block" ng-show="chgEmailForm.newEmail.$dirty && chgEmailForm.newEmail.$error.required">This field is required.</p>
  </div>

  <div class="form-group">
      <input class="form-control" type="email" name="confirmedNewEmail" placeholder="Confirm new email" ng-model="formData.confirmedEmail" match="formData.newEmail" required>

      <p class="help-block" ng-show="chgEmailForm.confirmedNewEmail.$dirty && chgEmailForm.confirmedNewEmail.$error.match" >Your emails must match.</p>
      <p class="help-block" ng-show="chgEmailForm.confirmedNewEmail.$dirty && chgEmailForm.confirmedNewEmail.$error.required ">This field is required.</p>
  </div>
</form>

<button class="btn btn-primary" ng-disabled="chgEmailForm.$invalid" ng-click="save()">Save</button>
<a ui-sref="account-settings.main" class="btn btn-danger">Cancel</a>

