Angular の親ルートと子ルートの間で値を渡す

1. 親ルートのすべてのパラメータを受け取るために空のルートを設定します

{
        path: 'menu/:flag', component: MenuIndexComponent, canActivate: [AuthGuard],
        children: [{
            path: '',    // 空路径
            children: [
                { path: 'menuInstitute', component: ManageInstituteListComponent, data: { title: 'xxx' } },
                { path: 'menuOrg', component: ManageStatisticsComponent, data: { title: 'xxx' } },
                { path: 'menuOrgInfo/:guid', component: StatisticsGroupInfoComponent, data: { title: 'xxx' } },
                { path: 'menuResearch', component: ManageResearchListComponent, data: { title: 'xxx' } },
                { path: 'menuConDoctor', component: ConnectDoctorComponent, data: { title: 'xxx' } },
            ]
        }]
    }

     空のパスを持つルート (空のルート) は、親ルートのパラメータとデータを継承します。これは、独自のパラメータを持つことができないため、通常は親ルートのパラメータとデータを独自のものとして使用します。

 

2. サブルートをコンポーネントレスルートとして設定する

おすすめ

転載: blog.csdn.net/sou_vyp/article/details/96129808