从Angularjs中的根URL中删除数字符号

时间:2013-10-24 08:23:56

标签: angularjs

Angular js将extenssion“/#”附加到我的网址(例如http://example.com/#/),但我希望我的根方向完全干净(没有/#).

有没有办法覆盖这个以获得一个干净的主页?

3 个答案:

答案 0 :(得分:1)

通过html5Mode

在配置中将true设置为$locationProvider
$locationProvider.html5Mode(true);

请参阅:http://docs.angularjs.org/guide/dev_guide.services.$location

答案 1 :(得分:0)

您需要配置$location提供程序才能删除网址中的哈希#This documentation介绍了如何配置html5模式。

此SO问题也有助于: Removing the fragment identifier from AngularJS urls (# symbol)

答案 2 :(得分:0)

我也遇到过这个问题。这可以通过

来实现
  1. 在配置

    中添加$ locationProvider.html5Mode(true)
    $locationProvider.html5Mode(true) 
    
  2. 在Index.html头标记中添加基本网址

    <base href="/app/index.html">