延迟加载并路由到模块中的组件

时间:2019-08-08 22:45:24

标签: angular

我的home.routing.module.ts上有以下路线:

const routes: Routes = [
  { path: '', component: HomeComponent, canActivate: [AnonymousGuard] },
  { path: 'press', component: PressComponent, canActivate: [AnonymousGuard] },
  { path: 'legal', component: LegalComponent, canActivate: [AnonymousGuard] },
  { path: 'contact', component: ContactComponent, canActivate: [AnonymousGuard] },
  { path: 'invite/:id', component: InviteComponent, canActivate: [AnonymousGuard] },
  { path: 'login', loadChildren: '../auth/auth.module#AuthModule' },
  // this doesn't work, it takes me to "login"
  { path: 'register', loadChildren: '../auth/auth.module#AuthModule' },
  { path: '**', redirectTo: '', pathMatch: 'full' }
];

我的auth.routing.module.ts上有以下路线:

const routes: Routes = [
  { path: '', component: LoginComponent, canActivate: [AnonymousGuard] },
  { path: 'login', component: LoginComponent, canActivate: [AnonymousGuard] },
  { path: 'forgot-password', component: ForgotPasswordComponent, canActivate: [AnonymousGuard] },
  // this works if if I type in "/login/register"
  { path: 'register', component: RegisterComponent, canActivate: [AnonymousGuard] },
  { path: 'verify-email', component: VerifyEmailComponent, canActivate: [AnonymousGuard] },
  { path: '**', redirectTo: '', pathMatch: 'full' }
];

我想让register可以访问register,而不是从家庭路由模块访问login/register,我该怎么做?

0 个答案:

没有答案