Angular 8:在根组件中使用模板进行延迟加载

时间:2019-07-10 13:47:09

标签: angular lazy-loading angular-routing

我有pages-routing.module.ts,它的子路由是这样的:

const routes: Routes = [
  {
    path: '',
    component: PagesComponent,
    children: [
    {
      path: 'persons',
      loadChildren: './persons/persons.module#PersonsModule'
    }
   ]
  }
]

以及在我的person-routing.module.ts中,我的孩子溃逃不正常

我的人员路由,.module.ts是:

const routes: Routes = [
  {
path: '',
component: PersonsComponent,
children: [
  {
    path: 'Test',
    component: TestComponent
  },
  {
    path: 'Sample',
    component: SampleComponent
  },
  {
    path: '',
    redirectTo: 'Sample',
    pathMatch: 'full'
  }
]
  }
]


@NgModule({
  declarations: [],
  imports: [
CommonModule,
RouterModule.forChild(routes)
  ],
  exports: [
RouterModule
  ]
})

当我路由到人员时,我想在我的PersonsComponent中的基本模板旁边打开“ SampleComponent”

<div class="row ml-0">
  <div class="col-xs-12 col-sm-6 col-md-5 col-lg-2 p-0 person-sidebar">
<nb-card size="small" class="mb-0">

</nb-card>
  </div>
  <div class="col-xs-12 col-sm-6 col-md-7 col-lg-10 pl-0" *ngIf="selectedUser">
<router-outlet></router-outlet>
  </div>
</div>

如何解决问题?

0 个答案:

没有答案