如何为AngularJS路由器设置根位置?

Val*_*sin 7 angularjs

我想开始导航http://mysite.com/hello/world,而不是从站点根目录开始.

例如

$routeProvider
  .when('/myurl', {
    templateUrl: 'mytmpl.html',
    controller: 'MyCtrl'
  });
Run Code Online (Sandbox Code Playgroud)

应该在我的网址时做出反应 http://mysite.com/hello/world/myurl

我怎么能这样做?

Ste*_*wie 6

将基本标记添加到用户导航到的时提供的主HTML文件中http://example.com/hello/world:

<base href="/hello/world/" />
Run Code Online (Sandbox Code Playgroud)

可以在开发人员指南/使用$ location找到更多信息