【发布时间】:2015-07-12 05:24:58
【问题描述】:
我正在尝试将 2 个(或更多)角度应用程序放在同一个 NodeJS 服务器上。基本上我想要的是:
- mydomain.com/clientapp - 最终用户应用程序,例如:买家
- mydomain.com/userapp - 将创建内容的用户。例如:一个卖家和他的产品
- mydomain.com/admin - 可以批准和删除内容的团队
我正在使用 ui-router ($stateProvider) 创建路由并加载页面。问题是我希望能够在我的应用程序上编写相对路径,这样如果我需要将基本 url 从 clientapp 重命名为 client,我不需要更改我所有的应用程序 url。
// this should be routed to admin/clients. Relative path
state('listClients', {
url: '/clients',
templateUrl: 'modules/clientes/views/list-clients.client.view.html'
}).
// this is how I am currently doing.
state('listClients', {
url: '/admin/clients',
templateUrl: 'modules/clientes/views/list-clients.client.view.html'
}).
正在发生的另一件奇怪的事情是,当我将 Angular 应用程序设置为 url 时,它会杀死最后一个 / 并添加 #!直接在应用名称上:
mydomain.com/app
becomes mydomain.com/app#!/main // ugly as hell
wanted mydomain.com/app/#!/main // little better
我该怎么做:
- 正确设置 AngularJS 和 ui-route 以使用其所有请求的基本路径?
- 解决难看的网址问题?
【问题讨论】:
-
您有问题吗?
-
是的。编辑了问题。
-
你的 html 头部有基本的 href= 元素吗?
-
我已经尝试过基本元素,但它似乎对某些库和#anchor 元素有一些副作用