title: Change $scope variable from submit() that sends http post request
body: <p>I can't set the value for <code>$scope</code> in a success response from <code>$http.post</code> request. The post request is sent through <code>submit()</code> function from a form submit using <code>ng-submit="submit()"</code>.</p>
  
  <pre><code>chatApp.controller('createController', ['$scope', '$http', '$location', function($scope, $http, $location) {
      $scope.fullname;
      $scope.create = function() {
          // console.log($scope.email, $scope.password, $scope.firstname, $scope.lastname);
          $http.post('ajax/createaccount.php', {
              'email': $scope.email,
              'username': $scope.username,
              'password': $scope.password, 
              'firstname': $scope.firstname, 
              'lastname': $scope.lastname
          }).then(function(data) {
              console.log("Success");
              $scope.fullname = data.config.data.firstname + " " + data.config.data.lastname;
              console.log($scope.fullname);
              $location.path("/createsuccess");
          }, function() {
              console.log("Error");
          })
      }
      console.log($scope.fullname);
  }]);
  </code></pre>
  
  <p>The first <code>console.log($scope.fullname)</code> outputs the right data. </p>
  
  <p>The second <code>console.log($scope.fullname)</code> outputs 'undefined'.</p>
  
  <p>I appreciate everyone who takes the time to look at this. </p>