使用laravel重定向angularjs中的问题

时间:2018-06-05 06:20:05

标签: angularjs ngroute

我创建了一个函数,用于在关闭选项卡后任何用户打开仪表板时检查用户登录。我将重定向到登录页面。它的工作正常但是当我在登录仪表板后重定向页面时,仪表板会重新加载自己多次,然后说找不到你正在寻找的laravel。

myApp.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider) {
        $locationProvider.html5Mode({
          enabled: true,
          requireBase: false
        });
        $routeProvider
        .when("/main", {
            templateUrl : "dashboard",
            controller: 'ecommerce'
        })
        .when("/add_product", {
            templateUrl : "add_product",
            controller: 'ecommerce'
        })
        .when("/ViewProducts", {
            templateUrl : "ViewProducts",
            controller: 'ecommerce'
        })
        .when("/view_orders", {
            templateUrl : "view_orders",
            controller: 'ecommerce'
        })
        .when("/create_offers", {
            templateUrl : "create_offers",
            controller: 'ecommerce'
        })


    }]);
myApp.controller('ecommerce',
    ['$http','$scope','fileUpload','offerFileUpload','categoryFileUpload',
     '$window','$interval','$location',

  function($http,$scope,fileUpload,offerFileUpload,categoryFileUpload,
      $window,$interval,$location){

$scope.check_login=function(){
            client_id=sessionStorage.getItem("client_id");
            client_name=sessionStorage.getItem("client_name");
            if(client_id==-1||client_id==null)
            {
                alert("Alert! Login Failed");
                window.location = "http://web.com/login"
            }
            else if(client_id!=""||client_id!=null)
            {
                window.location = "http://web.com/main"
            }
        }

//End of Controller
}]);
<html>
  <body ng-init="check_login()">
    <!-- Rest of the codes of dashboard panel -->
  </body>
</html

0 个答案:

没有答案