2015-06-11 46 views
0

我怎样才能获得角度页面刷新没有哈希链接?在页面刷新我的角度应用程序将错误,并不显示它刚刚显示的页面,所以我将html5Mode更改为false$locationProvider.html5Mode(false).hashPrefix("");),现在我可以刷新页面。但是我也在链接路径中看到恶意前缀​​。使角度页面刷新而不使用散列链接?

如何删除网址路径中的#,同时能够刷新页面?

+0

你在''中有''标记吗?另外,你使用的版本是1.3+吗? – scniro

+0

你的后端技术是什么? – arman1991

+0

@salniro是对这两个问题。 –

回答

1

服务器重写将在刷新时工作,尝试在您的服务器中添加中间件。 下面的示例grunt配置ID。 检查https://github.com/parmod-arora/angular-url-rewrite为nginx和grunt服务重写。

middleware: function (connect) {<br> 
     var middlewares = [];<br> 
     middlewares.push(modRewrite([ 
      '!/assets|\\.html|\\.js|\\.css|\\woff|\\ttf|\\swf$ /index.html' 
     ])); 

     middlewares.push(connect.static('.tmp')); 
     middlewares.push(connect().use(
      '/bower_components', 
      connect.static('./bower_components') 
     )); 
     middlewares.push(connect.static(appConfig.app)); 

     //middlewares.push(require('grunt-connect-proxy/lib/utils').proxyRequest); 
     return middlewares; 
     } 
1

您是否尝试过在html头部设置base?

<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <base href="/"> 
</head> 
+0

谢谢,是的,我试过这个。 –