AngularJS ui-router application has /#!/ in the URL [duplicate]

喜你入骨 提交于 2019-12-23 04:56:31

问题


I have an application with ui.router working normally, but another application the url has an "!" after "#"

Ex: http://localhost:8090/dev/#!/home

Why it happens?

The normal should be: http://localhost:8090/dev/#/home


回答1:


I suppose this happens because hashprefix is not set.

$locationProvider
  .hashPrefix('!');

I guess you can set it to empty string and that is why you don't see !.

Alternatively you can enable html5modethat will get rid ofhashbang` completely. Some older browsers don't support it, but generally not an issue, unless you need to support IE9 or something.

You can read about it e.g. here or here.

Long story short if you configure html5mode properly, then you won't have the hashbang that is required for routing in older browsers that do not support it.



来源:https://stackoverflow.com/questions/41365887/angularjs-ui-router-application-has-in-the-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!