如何为 AngularJS 路由器设置根位置? [英] How to set root location for AngularJS router?
本文介绍了如何为 AngularJS 路由器设置根位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从 http://mysite.com/hello/world
开始导航,而不是从网站根目录开始.
I would like to start navigation from http://mysite.com/hello/world
, not from site root.
例如
$routeProvider
.when('/myurl', {
templateUrl: 'mytmpl.html',
controller: 'MyCtrl'
});
应该在我的网址是 http://mysite.com/hello/world/myurl
我怎么能这样做?
推荐答案
将基本标签添加到当用户导航到 http://example.com/hello/world
:
Add base tag to the main HTML file that is being served when user navigates to http://example.com/hello/world
:
<base href="/hello/world/" />
更多信息可以在开发者指南/使用$location
这篇关于如何为 AngularJS 路由器设置根位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文