[英]How to correct Nested routing in angular 7?
Can somebody tell me how correct to set up routing when using multiple modules in my project?有人能告诉我在我的项目中使用多个模块时如何正确设置路由吗? I have app.module and administration.module with its under module gestion-profil.module some components declared in.I want to know how to connect modules and edit properly routing in administration.module.This is the architecture of my project:
我有 app.module 和 management.module 及其下模块 gestion-profil.module 中声明的一些组件。我想知道如何连接模块并在管理模块中正确编辑路由。这是我的项目的架构:
and this my code :这是我的代码:
app.routing.module.ts: app.routing.module.ts:
{
path: 'M_DROIT_USER',
loadChildren:'./features/administration-module/administration-module.module#AdministrationModule'
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
}
gestion-administration-routing.module.ts gestion-administration-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { GestionprofilComponent } from './gestion-
profile/Components/gestionprofil/gestionprofil.component';
const routes: Routes = [
{
path: '',
children: [{
loadChildren:'./features/administration-module/gestion-profile/gestion-
profile.module#GestionProfileModule'}]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
declarations: [GestionprofilComponent ],
exports: [RouterModule]
})
export class GestionAdministrationRoutingModule { }
administration-module.module.ts管理模块.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GestionProfileModule } from './gestion-profile/gestion-profile.module';
import { GestionprofilComponent } from './gestion-
profile/Components/gestionprofil/gestionprofil.component';
@NgModule({
declarations: [ ],
imports: [
CommonModule
]
})
export class AdministrationModule { }
gestion-profile.module.ts gestion-profile.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GestionprofilComponent } from './Components/gestionprofil/gestionprofil.component';
@NgModule({
declarations: [GestionprofilComponent],
imports: [
CommonModule,
]
})
export class GestionProfileModule { }
gestion-profil-routing.module.ts gestion-profil-routing.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';
import { GestionprofilComponent } from './Components/gestionprofil/gestionprofil.component';
const routes: Routes = [
{
path: '',
component: GestionprofilComponent,
pathMatch: 'full',
}
,
{
path: 'M_DROIT_GRP',
component: GestionprofilComponent,
},
];
@NgModule({
declarations: [],
imports: [
RouterModule.forChild(routes)
]
})
export class GestionProfilRoutingModule { }
how to resolve nested routin in angular 7?如何解决angular 7中的嵌套例程?
The problem looks to be with your gestion-administration-routing.module.ts
file.问题似乎与您的
gestion-administration-routing.module.ts
文件有关。 Change the routes to the following:将路由更改为以下内容:
const routes: Routes = [
{
path: '',
loadChildren: './features/administration-module/gestion-profile/gestion- profile.module#GestionProfileModule'
}
The compiler is complaining that you don't have a either loadChildren
or a component for the path.编译器抱怨您没有
loadChildren
或路径组件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.