Angularjs在POST函数中更改视图失败


Angularjs Changing view in POST function failed

我试图改变视图后的数据发送到我的php文件,但它似乎不工作。我已经在控制器中添加了&location。我不明白应该把$scope.auth();

放在哪里
 $scope.SignUp = function() {
   var Username = $scope.Username;
   var session_id = /SESS'w*ID=([^;]+)/i.test(document.cookie) ? RegExp.$1 : false;
   $scope.AccountStat ="USER";
   $scope.VerifyCode = session_id;
   $scope.Verifystat = "Verified";
   $scope.table = "Users";
   $scope.ajouter = 1;
   $scope.formdata;
    var path = $scope.path;
    var Password = $scope.formdata.Password;
    var ConPass = $scope.formdata.ConfirmPassword;
    var Firstname = $scope.formdata.Firstname;
    var Lastname = $scope.formdata.Lastname;
    var Email = $scope.formdata.Email;
    var Tel = $scope.formdata.Tel;
    var postdata = {
     'Username':$scope.formdata.Username,
     'Password': $scope.formdata.Password,
     'Firstname':$scope.formdata.Firstname,
     'Lastname':  $scope.formdata.Lastname,
     'Email':$scope.formdata.Email ,
     'Tel': $scope.formdata.Tel ,
     'AccountStat': $scope.AccountStat ,  
     'VerifyCode':$scope.VerifyCode ,
     'Verifystat':$scope.Verifystat,
        'ajouter':$scope.ajouter,
        'table':$scope.table,
        'app':true
        };
    var headers = {
            "Access-Control-Allow-Origin" : "*",
            "Access-Control-Allow-Methods" : "GET,POST,PUT,DELETE,OPTIONS",
            "Access-Control-Allow-Headers": "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
        }
     if (Password == ConPass){
     $http.post(path, postdata, headers
                    ).success(function(data, status, headers, config) {
                        if (data)
                        {
                            console.log(data);
                            $scope.reset();
                            $scope.getData();
                $http({
                method  : 'POST',
                url     : 'http://localhost/sendmail.php',
                data    : $.param($scope.formdata),  //param method from jQuery
                 headers : { 'Content-Type': 'application/x-www-form-urlencoded' } //set the headers so angular passing info as form data (not request payload)
            }).success(function(data){
                console.log(data);
                if (data.success) { //success comes from the return json object
                   $scope.auth(); <---- trying to use function, but failed fucntion doesn't work.
                } else {
                 $scope.resultMessage = data.message;
                    $scope.result='bg-danger';
                }
            });
                        }
                    }).error(function(data, status) { // called asynchronously if an error occurs
// or server returns response with an error status.
                        console.log(data);
                    });
    }else{
       alert('กรุณากรอก Password ให้ตรงกัน');
    }
     }
       $scope.auth = function(){  <---function declared
       $location.url('/view1');
    };   

auth函数未被提升

$scope.auth = function () {  <---function declared
    $location.url('/view1');
};

应该在$scope.signUp之前