我的Angular 2项目中有多个router-outlet
,如下所示:
<router-outlet></router-outlet>
<router-outlet name="secondary"></router-outlet>
<router-outlet name="third"></router-outlet>
路由信息如下:
{
path : 'mainroute',
component: MainComponent,
data : {
mode: 'normal'
}
},
{
path : 'action',
component: SecondaryComponent,
outlet : 'secondary',
data : {
mode: 'special'
}
},
例如,如果我有路由localhost:4200/mainroute(secondary:action)
,我只能从主路由中检索数据,如何从辅助router-outlet
检索数据?
export class MainComponent implements {
constructor (private route: ActivatedRoute) {
route.data.subscribe((data: any) => {
console.log(data); // I managed to get the data from main route here
// how can I subscribe the data from secondary route here
});
}
}