angular 父子路由之间传值

一、 设置空路由接收父路由所有参数

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

     空路径路由(空路由)会继承它的父路由的参数和数据。这是因为它不能拥有自己的参数,所以,它通常会把其父路由的参数和数据当做自己的使用。

二、子路由配置成无组件路由

猜你喜欢

转载自blog.csdn.net/sou_vyp/article/details/96129808