Angular 网络应用有额外的!在 url

Angular web app having extra ! in the url

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

Angular 1.6 版增加了一个“!”到 $location.. 查看下面的 angular 页面...

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

$location:

Due to aa077e8, the default hash-prefix used for $location hash-bang URLs has changed from the empty string ('') to the bang ('!'). If your application does not use HTML5 mode or is being run on browsers that do not support HTML5 mode, and you have not specified your own hash-prefix then client side URLs will now contain a ! prefix. For example, rather than mydomain.com/#/a/b/c the URL will become mydomain.com/#!/a/b/c.

If you actually want to have no hash-prefix, then you can restore the previous behavior by adding a configuration block to you application:

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