同一模板中的 Angular2 多个路由器插座 [英] Angular2 multiple router-outlet in the same template
本文介绍了同一模板中的 Angular2 多个路由器插座的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在同一个模板中可以有多个路由器插座吗?
Is it possible to have multiple router-outlet in the same template?
如果是,那么如何配置路由?
If yes then how to configure the routes?
我使用的是 angular2 测试版.
I am using angular2 beta.
推荐答案
可以,但需要使用辅助路由.您需要为路由器插座命名:
yes you can, but you need to use aux routing. you will need to give a name to your router-outlet:
<router-outlet name="auxPathName"></router-outlet>
并设置您的路线配置:
@RouteConfig([
{path:'/', name: 'RetularPath', component: OneComponent, useAsDefault: true},
{aux:'/auxRoute', name: 'AuxPath', component: SecondComponent}
])
RC.5 更新辅助路由发生了一些变化:在您的路由器插座中使用名称:
Update for RC.5 Aux routes has changed a bit: in your router outlet use a name:
<router-outlet name="aux">
在您的路由器配置中:
{path: '/auxRouter', component: secondComponentComponent, outlet: 'aux'}
这篇关于同一模板中的 Angular2 多个路由器插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文