2016-11-16 88 views
2

在我的應用程序中,當auth成功時,我重定向到/users。它工作正常,我也在用戶頁面。但是,當我刷新頁面,我得到一個錯誤:角度ui路由器發現刷新頁面上的問題

不能得到/用戶

這是什麼意思?

除了我的基地位置是/這是login頁,以及在用戶輸入路徑作爲/login - 我不是重定向到/。什麼是問題?

這裏是我的router配置:

(function(){  
    "use strict";  
    angular.module('meanOffice') 
     .config(routeConfig); 


    function routeConfig($locationProvider, $stateProvider, $urlRouterProvider){ 

     $stateProvider 
      .state('login', { 
       url:'/', 
       templateUrl : 'app/views/pages/login/login.html', 
       controller : 'mainController as main' 
      }) 
      .state('users', { 
       url:'/users', //refresh getting error 
       templateUrl : 'app/views/pages/users/users.html', 
       controller : 'usersController as users' 
      }) 


     $locationProvider.html5Mode({ 
      enabled: true, 
      requireBase: false 
     }); 


     $urlRouterProvider.otherwise('/');//when type '/login' throw error 

    } 

})(); 
+0

能告訴你什麼是'瀏覽器的Console'提筆給你?並請寫下有關錯誤的全部內容。 – StepUp

回答

1

這意味着你的服務器沒有設置正確。

爲了使用HTML5模式,所有請求都需要指向您的入口點。 關於如何設置服務器的詳細信息,請參閱:https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode

+0

我正在使用'node'作爲我的服務器。如果您有任何具體的方法,請告訴我們 – user2024080

+1

本身的'node'不能用作服務器。我猜你正在使用'express',因爲它是最常用的服務器。您可以在鏈接頁面上查看「Express Rewrites」,看看您的設置是否正確。 –

0

設置您的明確程序:

app.route('/*').get(function(req, res) { 
    return res.sendFile(path.join(config.root, 'index.html')); 
});