Angular2多个路由器出口在同一模板中 [英] Angular2 multiple router-outlet in the same template
问题描述
在同一模板中可以有多个路由器出口吗?
Is it possible to have multiple router-outlet in the same template?
如果是,那么如何配置路由?
If yes then how to configure the routes?
我正在使用angular2 beta.
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}
])
查看以下示例: http://plnkr.co/edit/JsZbuR?p=preview 也是这段视频: https://www.youtube.com/watch ?v = z1NB-HG0ZH4& feature = youtu.be
check out this example: http://plnkr.co/edit/JsZbuR?p=preview Also this video: https://www.youtube.com/watch?v=z1NB-HG0ZH4&feature=youtu.be
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屋!