模块

创建模块:ng g ng-alain:module sys
image.png
生成的文件如下:
sys.module.ts

  1. import {NgModule, Type} from '@angular/core';
  2. import {SharedModule} from '@shared';
  3. import {SysRoutingModule} from './sys-routing.module';
  4. const COMPONENTS: Type<void>[] = [];
  5. const COMPONENTS_NOROUNT: Type<void>[] = [];
  6. @NgModule({
  7. imports: [
  8. SharedModule,
  9. SysRoutingModule
  10. ],
  11. declarations: [
  12. ...COMPONENTS,
  13. ...COMPONENTS_NOROUNT
  14. ],
  15. })
  16. export class SysModule {
  17. }

sys-routing.module.ts

  1. import {NgModule} from '@angular/core';
  2. import {RouterModule, Routes} from '@angular/router';
  3. const routes: Routes = [];
  4. @NgModule({
  5. imports: [RouterModule.forChild(routes)],
  6. exports: [RouterModule]
  7. })
  8. export class SysRoutingModule {
  9. }
  1. const routes: Routes = [
  2. {
  3. path: '',
  4. component: LayoutBasicComponent,
  5. children: [
  6. { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
  7. { path: 'dashboard', component: DashboardComponent, data: { title: '仪表盘' } },
  8. // 业务子模块
  9. {path: 'sys', loadChildren: () => import('./sys/sys.module').then((m) => m.SysModule)} // 命令生成的路由
  10. ]
  11. }
  12. ]

页面

在 sys 模块下创建页面
ng g ng-alain:list log -m=sys
image.png