带模块的Angular9路由

时间:2020-08-04 12:27:09

标签: angular typescript routes angular9

我创建了auth-routing.module.ts来包含组件模块,我认为我应该包含一些东西,但是我不知道我应该包含例如组件!但是它已经包含在组件内部每个模块的模块中,请问怎么了?我该怎么办? 使用以下代码:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthComponent } from './auth.component';

const routes: Routes = [

  {
    path: "",
    component: AuthComponent,
    children: [
        {
            path: "",
            redirectTo: "login",
            pathMatch: "full"
        },
        {
            path: "login",
            loadChildren: () =>
                import("./login/login.module").then(m => m.LoginModule)
        },
        {
            path: "reset-password",
            loadChildren: () =>
                import("./reset-password/reset-password.module").then(
                    m => m.ResetPasswordModule
                )
        },
        {
            path: "forget-password",
            loadChildren: () =>
                import("./forget-password/forget-password.module").then(
                    m => m.ForgetPasswordModule
                )
        }
    ]
}
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class AuthRoutingModule { }

以及在app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
  path: "home",
  loadChildren: () =>
      import("./main/pages/home/home.module").then(
          m => m.HomeModule
      )
},
{
  path: "auth",
  loadChildren: () =>
      import("./main/pages/auth/auth.module").then(m => m.AuthModule)
},
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

路由无法正常运行,我不知道为什么!

0 个答案:

没有答案