IONIC-从视图中删除上一页

时间:2017-08-01 17:01:54

标签: angularjs ionic-framework

我目前正在使用两个页面,它们都使用一个标签视图。当用户首次启动页面时,首先显示登录页面,当用户登录时,他/她被定向到也使用相同标签视图的不同页面。我想在用户登录后从历史记录中删除主页。当用户登录后面的当前脚本已从标题中禁用时,但当用户点击选项卡时,它会再次将他带到登录页面。

.controller('login_ctrl',['$scope','$http','$timeout','$ionicModal','$ionicLoading','$ionicPopup','$location','$cordovaToast','$location','$ionicHistory',function($scope,$http,$timeout,$ionicModal,$ionicLoading,$ionicPopup,$location,$cordovaToast,$location,$ionicHistory){

            ///alert if connection fails
                $scope.connect = function() {
                var alertPopup = $ionicPopup.alert({
                title: 'Error',
                template: '<p align="center">Internet Connectivity Problem</p>',
                });
                };

    ///alert if username or password is wrong
    $scope.mainloginAlert = function() {
                var alertPopup = $ionicPopup.alert({
                title: 'Error',
                template: '<p align="center">Incorrect Username or Password</p>',
                });
                };


    $scope.mainlogin= function(){
    $ionicLoading.show({template: '<p>Please Wait...</p><ion-spinner></ion-spinner>'});
        event.preventDefault();
        $http.post("http://sample.com/login.php",
        {'user':$scope.login_username,'pass':$scope.password})
        .success(function(data){
        console.log(JSON.stringify(data));
        $scope.data_msg=(data.message)



            if($scope.data_msg==="Incorrect Username or Password"){
            $scope.mainloginAlert()
            {$ionicLoading.hide();}
        }
                else{
                if(data != "Incorrect Username or Password"){
                localStorage.setItem("account_number",(data[0].Account_Number));
                $scope.account_number= localStorage.getItem("account_number");

                $http.post("http://gwclebilling.com/blay/server_scripts/customer.php",{'id':$scope.account_number}).success(function(data){
                console.log(JSON.stringify(data));

                $location.path ('tab/account');
                {$ionicLoading.hide();}
                    })
                    $ionicHistory.nextViewOptions({
                disableBack: true
                })
                    }
                }

                }).error(function(error){
                console.error(error);
                {$ionicLoading.hide();}
                $scope.connect()
                    });

  }


}])

1 个答案:

答案 0 :(得分:0)

首次登录后,将$ scope.account_number存储到localstorage中。

scala> val corr_df = drop_date_df.select(
     |                 corr('amount,'residuals).as("amount_residuals_corr"),
     |                 corr('prediction,'residuals).as("prediction_residual_corr"))
corr_df: org.apache.spark.sql.DataFrame = [amount_residuals_corr: double, prediction_residual_corr: double]

scala> corr_df.show
+---------------------+------------------------+
|amount_residuals_corr|prediction_residual_corr|
+---------------------+------------------------+
|   0.7829393309615287|      -0.252053129068828|
+---------------------+------------------------+

当你下次打开时,检查这是未定义的或不是。像

localStorage.accNum = $scope.account_number;

用户退出后,您可以清除localStorage.accNum。像

localStorage.accNum =&#34;&#34;;