加载/路由Angular 2(官方版本2.0.0)

时间:2016-09-21 11:43:03

标签: angular typescript angular2-routing

如果我必须访问angular2应用程序,应如何配置路由器 页面直接(没有任何router-outlet指令)

当必须在iframe中打开应用程序时,这个棘手的时刻到来了。
所以 iframe.src = localhost/PathParam1/PathParam2/ng2/page1

你知道URL_BASE_HREF应该是什么,或者我错过了什么。

对于以前版本的angular(全部为RC6),URL_BASE_HREF为http://localhost/PathParam1/PathParam2/ng2

然后路由工作。

现在当我使用相同的逻辑时,但如果我在

加载应用程序
localhost/PathParam1/PathParam2/ng2/page1

然后它会自动更改为

localhost/somePathParam/someOtherPathParam/ng2/PathParam1/PathParam2/ng2/page1

你知道如何做到这一点吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

它已经解决了。我创建了一个小的lib,它提供了当前的基本URL。例如,如果我有localhost / PathParam1 / PathParam2 / ng2 / page1,该方法将返回localhost / PathParam1 / PathParam2 / ng2然后我有子导航到page1