我正在自定义 ngx-admin 模板,我试图在 app 模块中添加新模块。并在 app-routing.module.ts 中添加了它的路由。但是当我尝试打开它时它不起作用。它在加载时卡住了。控制台也没有错误。所以我不明白可能是什么问题。
我在页面外添加了这个 SignModule,而不是在页面内
应用程序路由.module.ts
import { ExtraOptions, RouterModule, Routes } from "@angular/router";
import { NgModule } from "@angular/core";
import {
NbAuthComponent,
NbLoginComponent,
NbRegisterComponent,
NbLogoutComponent,
NbRequestPasswordComponent,
NbResetPasswordComponent,
} from "@nebular/auth";
const routes: Routes = [
{
path: "pages",
loadChildren: () =>
import("../app/pages/pages.module").then(m => m.PagesModule),
},
//Newly added Module
{
path: "sign",
loadChildren: () =>
import("../app/sign/sign.module").then(m => m.SignModule),
},
{
path: "auth",
component: NbAuthComponent,
children: [
{
path: "",
component: NbLoginComponent
},
{
path: "login",
component: NbLoginComponent
},
{
path: "register",
component: NbRegisterComponent
},
{
path: "logout",
component: NbLogoutComponent
},
{
path: "request-password",
component: NbRequestPasswordComponent,
},
{
path: "reset-password",
component: NbResetPasswordComponent,
},
],
},
{ path: "", redirectTo: "sign", pathMatch: "full" },
{ path: "**", redirectTo: "pages" },
];
const config: ExtraOptions = {
useHash: false,
enableTracing: true,
};
@NgModule({
imports: [RouterModule.forRoot(routes, config)],
exports: [RouterModule],
})
export class AppRoutingModule {}
这是我添加的新模块。标志模块
sign.module.ts 文件
import { NgModule } from '@angular/core';
import { ThemeModule } from '../@theme/theme.module';
import { SignComponent } from './sign.component';
import { SigninModule } from './signin/signin.module';
import { SignupModule } from './signup/signup.module';
import { SignRoutingModule } from './sign-routing.module';
@NgModule({
imports: [
SignRoutingModule,
ThemeModule,
SigninModule,
SignupModule,
],
declarations: [SignComponent],
})
export class SignModule { }
标志路由.module.ts
import { NgModule, } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SigninComponent } from './signin/signin.component';
import { SignupComponent } from './signup/signup.component';
import { SignComponent } from './sign.component';
const routes: Routes = [
{
path: '',
component: SignComponent,
children: [
{
path: 'signin',
component: SigninComponent
},
{
path: 'signup',
component: SignupComponent
},
{
path: '',
redirectTo: 'signin',
pathMatch: 'full',
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class SignRoutingModule { }