Pass value between angular parent and child routes

1. Set an empty route to receive all parameters of the parent route

{
        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' } },
            ]
        }]
    }

     A route with an empty path ( empty route ) will inherit the parameters and data of its parent route. This is because it cannot have its own parameters, so it usually uses the parameters and data of its parent route as its own.

 

2. Configure sub-routes as component-less routes

Guess you like

Origin blog.csdn.net/sou_vyp/article/details/96129808