angular 重定向到身份验证

angular redirect to auth

我尝试使用 Angular CLI 和路由。 我想做一些路由 /auth/login 默认 /auth/register等

我有3个模块 应用程序 授权 登录 在每个级别的模块上我都定义了路线 app.module

const routes: Routes = [
  { path: '', pathMatch: 'full', redirectTo: 'auth' },
  { path: '**', component: PageNotFoundComponent }
];

app/auth.模块

const routes: Routes =  [
  {
    path: 'auth',
    children: [
      { path: '', pathMatch: 'full', redirectTo: 'login' },
      { path: 'login', loadChildren: './login/login.module#LoginModule' },
      { path: 'register', loadChildren: './register/register.module#RegisterModule' },
    ]
  }
];

在应用中/auth/login

const routes: Routes = [
  { path: '', component: LoginComponent }
];

在 运行 我的应用程序之后,我希望重定向到 auth/login 但我有来自

的 404 页
{ path: '**', component: PageNotFoundComponent }

我不会轻描淡写为什么会这样 我做错了什么? 存储库可以在这里找到: https://bitbucket.org/kajzarowie/tst/src/ef5708f45465a2c1b5d598253352228be2d3bddd/src/app/?at=master

直接重定向到登录

const routes: Routes = [
  { path: '', pathMatch: 'full', redirectTo: 'auth/login' },
  { path: '**', component: PageNotFoundComponent }
];

我找到了解决方案。 我需要做的是在 app-routing.module 中添加 import AuthModule :)