【发布时间】:2021-04-15 07:39:49
【问题描述】:
在 Angular 中,我有这个用于导入模块的主应用程序路线,并将布局组件设置为所有导入的路线,但我想更改某些路线的布局,例如模块中的打印页面,请参阅主要路线:
const routes: Routes = [
{
path: '',
component: LayoutComponent,
children: [
{
path: 'buySell',
loadChildren: () =>
import('../modules/buySell/buySell.module').then(
(m) => m.BuySellModule
),
},
{
path: 'product',
loadChildren: () =>
import('../modules/product/product.module').then(
(m) => m.ProductModule
),
},
{
path: '',
redirectTo: '/dashboard',
pathMatch: 'full',
},
{
path: '**',
redirectTo: 'error/404',
},
],
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class PagesRoutingModule { }
并导入所有模块路由并为所有设置布局组件,现在我想在布局不同的模块中创建一个打印页面,请参阅子模块:
const routes: Routes = [
{
path: '',
component: BuySellComponent,
children: [
{
path: 'preInvoice',
// canActivate: [PermissionGuard],
component: BuySellPreInvoiceListComponent,
// data: {permissions: [ ]},
},
{
path: 'preInvoice/add',
component: BuySellPreInvoiceEditComponent
},
{
path: 'preInvoice/edit/:id',
component: BuySellPreInvoiceEditComponent
},
{ path: '**', redirectTo: 'oopsRoutingFile', pathMatch: 'full' },
],
},
// this is my print and I need to change the parent layout
{
path: 'preInvoice/print/:id',
component: BuySellPreInvoicePrintComponent,
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class BuySellRoutingModule {}
如何删除或覆盖父布局组件?
【问题讨论】:
标签: angular typescript angular-ui-router