2017-03-03 34 views
0

我在我的角度應用程序中使用stateProvider時遇到了一些問題。我想消除#的URL地址,我用這個$ locationProviderhtml5Mode。但在此之後,當我想要轉到其他url狀態(例如mysite.com/state)時,應用程序返回'無法獲取'(delete##一切正常)。有沒有可能解決這個問題?從我的角度應用程序中的URL中消除##

$stateProvider 
    .state('home', { 
    url: '/', 
    templateUrl: 'components/home.html' 
    }) 
    .state('state', { 
    url: '/state', 
    templateUrl: 'components/state.html', 
    }); 

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

尋找答案:http://stackoverflow.com/questions/16677528/html5和hashbang-mode-link-rewriting之間的位置切換 – Gaurav

+0

[$ location/html5和hashbang模式之間的切換/鏈接重寫]的可能重複(http://stackoverflow.com/questions/16677528/location-switching-between-html5-and-hashbang-mode-link-rewriting) –

+0

我嘗試用這個鏈接解決我的問題,但它不能解決我的問題lem –

回答

0

我看到你已經設置HTML5模式爲真,但你也有你的<head>標籤href="/"設置:這裏

<html> 
    <head> 
    <base href="/"> 
    </head> 
</html> 
+0

是的,我忘了告訴基地標籤。我在index.html –

相關問題