导入的带有路由的惰性模块将覆盖其他模块

时间:2019-08-13 06:21:47

标签: angular angular2-routing

我正在尝试将一个懒惰模块IdCardModule导入另一个名为EmployeeModule的懒惰模块中,但是当我尝试打开EmployeeModule路由时   / employee / create ,它总是打开IdCardModule的路由

const routes: Routes = [
  {
    path: '', component: EmployeesComponent,

    children: [
      { path: '', component: OverviewComponent },
      { path: 'create', component:CreateComponent}
    ]
  }
];

    @NgModule({
      imports: [
        RouterModule.forChild(routes),
      ],
      declarations: [
        EmployeesComponent,
        OverviewComponent,
        CreateComponent
      ],
      providers: [
        EmployeeDetailService
     ]})
    export class EmployeesModule { }

IdCardMododule

const routes: Routes = [
  {
    path: '', component: IdCardComponent,

    children: [
      { path: '', component: OverviewComponent },
      { path: 'CreateComponent', component:CreateIdCardComponent}
    ]
  }
];

    @NgModule({
      imports: [
        RouterModule.forChild(routes),
        IdCardModule
      ],
      declarations: [
        ICardComponent,
        OverviewComponent,
        CreateIdCardComponent
      ],
      providers: [
        IdCardService
     ]})
    export class IdCardsModule{ }

带有子路线的AppModule

const routes = [
  { path: '', loadChildren: './modules/dashboard/dashboard.module#DashboardModule' },
    { path: 'employee', loadChildren: './modules/employees/employees.module#EmployeesModule', canActivate: [RouteGuard] },
    { path: 'idcard', loadChildren: './modules/identity-card/id-cards.module#IdCardsModule', canActivate: [RouteGuard] },
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes),
     })
  ],

0 个答案:

没有答案