角度网络应用程序有额外的!在网址中

时间:2016-12-14 02:53:24

标签: html angularjs angular-routing route-provider

我有一个基本的Angular webapp在ec2 ubuntu 16.04上运行,使用路由($ routeProvider)。当我打开应用程序主页说example.com时,不会打开http://example.com/#/而是打开http://example.com/#!/还有一个额外的!这搞乱了整个网址/路由结构。不知道我做错了什么,请建议。

1 个答案:

答案 0 :(得分:1)

Angular版本1.6增加了一个“!”到$ location ..检查下面的角度页面......

https://docs.angularjs.org/guide/migration#commit-aa077e8

  

<强> $位置:

     

由于aa077e8 ,$ location hash-bang使用的默认哈希前缀   网址已从空字符串('')更改为bang('!')。如果你的   应用程序不使用HTML5模式或正在浏览器上运行   不支持HTML5模式,并且您尚未指定自己的模式   hash-prefix然后客户端URL现在包含一个!字首。对于   例如,URL将成为mydomain.com/#/a/b/c而不是   mydomain.com /#!/ A / B / C

     

如果你真的想要没有hash-prefix,那么你可以恢复   通过向您的应用程序添加配置块来执行以前的行为:

appModule.config(['$locationProvider', function($locationProvider) {
  $locationProvider.hashPrefix('');
}]);