title: Angularjs Form is getting submitted before the email validation
body: <p>I have an <code>angularjs</code> form which is to be submitted based on the email validation but my form is getting submitted before the email validation call back. here is the register controller </p>
  
  <pre><code>**************** registerctrl.js **********************
     angular.module('myapp').controller('registerctrl',function($scope, emailValidationService,registerationValidationService ){
  $scope.validateForm = function validateForm() {
  
      $scope.registerationForm.$submitted = true;
      $scope.registerationForm.email.$error.alreadyRegisteredEmailID = false;
      /*
          If the form is invalid it returns
      */
      var emailId = emailValidationService.getValidationResult($scope.user.email).then(function(promise){
          $scope.registerationForm.email.$error.alreadyRegisteredEmailID = promise.data;
          return promise.data;
      },function(promise){
          console.log("There is an error while validating the email ID"+$scope.user.email);
      });
      if (! registerationValidationService.validForm($scope.registerationForm)) {
          return;
      }
      /*
          If the email is already registerated returning the form
      */
      else if($scope.registerationForm.email.$error.alreadyRegisteredEmailID) {
          $scope.registerationForm.$invalid= true;
          $scope.registerationForm.email.$error.alreadyRegisteredEmailID = true;
          return;
      }
      /*
          If the form is valid saving the form and redirecting to success form
      */
      else{
          registerationValidationService.saveRegisterationForm($scope.user).then(function(promise){
              if(promise){
                  $location.path('/registration-response');
              }
              else
                  return;
          },function(promise){
              console.log("There is an error while submitting the form");
              });
          }
      };
  
        });
  
   };
  </code></pre>
  
  <p>And the below code is for email validation service js file</p>
  
  <pre><code>***************************** emailValidationService.js *****************
  angular.module('myapp').factory('emailValidationService',function($http,$log){
  return {
      getValidationResult : function(email){
          var promise = $http.get('data/email-exists.json').success(function(data,status,headers,config){
                  //$http.post('/myapp/api/email-exists.json', { email: email }).success(function(data,status,headers,config){
                      console.log("Hey I am gng to return the value be ready to capture it ")
                      return data;
                  }).error(function(data,status,headers,config){
                      console.log("Hey there is something went wrong here")
                      alert("Something went wrong");
                  });
              return promise;
          }
  
      };
  });
  </code></pre>
  
  <p>And this is my registration form validation service</p>
  
  <pre><code>********************* registerationValidationService *****************
  angular.module('myapp').factory('registerationValidationService', function($http, $log){
  return{
  saveRegisterationForm : function(user) {
  
          var promise = $http.post('data/register.json', {
                  firstName : user.firstName,
                  lastName : user.lastName,
                  email : user.email,
                  mobileNumber : user.mobileNumber
              }).success(function(data, status, headers, config) {
                  if (data.message == 'success') {
                      console.log("Data saved successfully")
                      return true;
                  } else {
                      console.log("There is an error while saving the data");
                      return false;
                  }
              }).error(function(data, status, headers, config) {
                  console.log("Exception happened during your form submission have a look at post url and data");
              });
              return promise;
          }
  
  
      };
  });
  </code></pre>
  
  <p>Please help me to resolve this issue</p>