Angular 2 loadChildren 不使用 canActivateChild

Angular 2 loadChildren not working with canActivateChild

我正在尝试使用 Angular2 延迟加载一些模块。我可以让它工作,但是当我将它与 canActivateChild 一起使用时,它会阻止导航但加载模块,我不知道我是否需要做任何其他事情,但我只想加载模块,如果我是启用访问路由。例如,这是一个管理仪表板,我只想在用户登录时加载 AdminModule。

这是我的主模块路由:

export const routing = [
    { path: '', redirectTo: 'home', pathMatch: 'full' },
    { path: 'login', component: LoginComponent },
    {
        path: '',
        canActivateChild: [AuthGuard],
        children: [
            { path: 'home', component: HomeComponent },
            { path: 'adm', loadChildren: './admin/admin.module#AdminModule' },
        ]
    },
    { path: '**', component: NotFoundComponent },
];

这是我的管理员路由:

export const adminRouting = [
    { path: '',
        children: [
            { path: 'client', component: ClientComponent },
            { path: 'support', component: SupportComponent },
            // more routes
        ]
    },
];

就像我说的,导航中的一切都按预期工作,但是当我没有登录时,我想阻止加载 lazyLoad 模块。

根据 the routing guide 在 angular 上的说法,我认为您必须使用 canLoad 而不是 canActivate