有角的网络应用程序有额外的!在网址中 [英] Angular web app having extra ! in the url

查看:138
本文介绍了有角的网络应用程序有额外的!在网址中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

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



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


$ location:

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


如果您确实不想使用哈希前缀,那么您可以通过向应用程序添加配置块来恢复
之前的行为:



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



I have a basic Angular webapp running on ec2 ubuntu 16.04, using routing($routeProvider). When I open the application home page say example.com, instead of opening http://example.com/#/ it opens http://example.com/#!/ there is an extra ! which is messing up the whole url/routing structure. Not sure what I am doing wrong, Please advice.

解决方案

Angular version 1.6 adds a "!" to $location.. check the angular page below...

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('');
}]);

这篇关于有角的网络应用程序有额外的!在网址中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆