AngularJS路由问题的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 :(我创build我的链接像这样:

 <div class="read-more"><a href="#article">Lire plus...</a></div> 

我的坏链接: http:// localhost:10001 /#!/#文章

vs好链接是: http:// localhost:10001 /#!/ article

谁错了?

谢谢

PS我使用节点Lite服务器

这个http:// localhost:10001 /#!/ article是正确的url。

原因是,如果浏览器是HTML5浏览器,AngularJS会将其redirect到#!

否则,它将只是#

请阅读$location这个文档 ,了解更多关于这个的原因。

  • 在旧版浏览器中打开常规url – >redirect到hashbangurl
  • 在现代浏览器中打开hashbangurl – >重写成一个普通的URL