[英]AngularJS routing issue bad url
在我的應用中生成了我的路線:
app.config( function($routeProvider){
$routeProvider
.when('/',{
templateUrl: './partials/home/home.html',
controller: 'mainCtrl'}
)
.when('/article',{
templateUrl: './partials/article/article.html',
controller: 'articleCtrl'}
)
.otherwise({
redirectTo: '/'
});
});
工作正常!
但是鏈接是bas :(我這樣創建鏈接:
<div class="read-more"><a href="#article">Lire plus...</a></div>
我的錯誤鏈接: http:// localhost:10001 /#!/#article
vs好的鏈接是: http:// localhost:10001 /#!/ article
誰錯了?
謝謝
PS我使用節點精簡版服務器
此http:// localhost:10001 /#!/ article是正確的url。
原因是,如果瀏覽器是HTML5瀏覽器,AngularJS會將其重定向到#!
否則只會是#
。
在$location
上閱讀此文檔 ,以了解有關發生這種情況的更多信息。
- 在舊版瀏覽器中打開常規URL->重定向到hashbang URL
- 在現代瀏覽器中打開hashbang URL->重寫為常規URL
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.