Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 加载不同路由模块中的子节点_Angular_Angular Routing_Angular Router - Fatal编程技术网

Angular 加载不同路由模块中的子节点

Angular 加载不同路由模块中的子节点,angular,angular-routing,angular-router,Angular,Angular Routing,Angular Router,我尝试了太多的方法,并坚持新的方案 下面是我的app.module.ts export const ROUTES: Routes=[ { path: '', component: LoginComponent}, { path: 'maincontent', loadChildren: './main-content/maincontent.module#MainContentModule' }] export const RO

我尝试了太多的方法,并坚持新的方案

下面是我的app.module.ts

export const ROUTES: Routes=[
    { 
      path: '', component: LoginComponent},
    { 
      path: 'maincontent', 
      loadChildren: './main-content/maincontent.module#MainContentModule'
    }]
export const ROUTES: Routes = [
  {
    path: 'maincontent',
    component: MainContentComponent,
    children: [
      { path: 'dashboard', 
        loadChildren: './dashboard/dashboard.module#DashboardModule' },
    ] 
      }];
下面是我的maincontent.module.ts

export const ROUTES: Routes=[
    { 
      path: '', component: LoginComponent},
    { 
      path: 'maincontent', 
      loadChildren: './main-content/maincontent.module#MainContentModule'
    }]
export const ROUTES: Routes = [
  {
    path: 'maincontent',
    component: MainContentComponent,
    children: [
      { path: 'dashboard', 
        loadChildren: './dashboard/dashboard.module#DashboardModule' },
    ] 
      }];
在dashboard.module.ts中,我有以下路径

export const ROUTES: Routes = [
  {
    path:'dashboard', component:DashboardComponent,
    children:[
      {
        path:'application',component:ApplicationDetailsComponent
      }
    ]
  }
]

问题是,当我登录时,我已经直接导航到仪表板页面,但它没有显示页面的任何内容。我哪里出错了?有人能给我指点一下吗?我想你应该把孩子们的路线设置成空字符串

maincontent.module.ts

导出常量路由:路由=[
{
路径:“”,而不是路径:“maincontent”,
组件:MainContentComponent,
儿童:[
{
路径:“仪表板”,
loadChildren:'/仪表板/仪表板.模块#仪表板模块'
},
]
}];
仪表板模块.ts

导出常量路由:路由=[
{
路径:“”,而不是路径:“仪表板”
组件:仪表板组件,
儿童:[
{
路径:“应用程序”,组件:ApplicationDetailsComponent
}
]
}
]

我也经历过类似的事情,但结果是,我缺少了一个依赖项


在你的情况下,@yurzui的答案看起来是正确的

它没有显示任何错误,但仪表板组件的内容不显示。字符串不起作用。它只是导航到仪表板组件。登录后您想去哪里?为什么它在我的示例中起作用?您在路径中提到了空字符串,我尝试了相同的方法,但它没有显示登录页面,而是在登录后显示仪表板内容。我想导航到仪表板,其中maincontent具有工具栏和侧菜单,然后当我单击任何侧菜单内容时,应在该侧加载特定内容菜单选项之一是呈现我的仪表板内容在我的示例中,首先是登录页面,然后转到仪表板