嵌套布线角度6不触发

问题描述 投票:0回答:1

[大家好,我有带有组件的模块,我想在其中之一中添加组件,因为我有管理员,这个模块有子页面,并且正在路由

const routes: Routes = [
  {
    path: '',
    component: AdminComponent,
    children: [
      { path : 'Dashboard' , component: DashboardComponent},
      // { path: 'User', component: UserComponent },
      { path: 'User', loadChildren: './user/user.module#UserModule'},
      { path: '', redirectTo: 'Dashboard', pathMatch: 'full' },
    ],
  },
  { path: '**', component: SystemErrorComponent }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class AdminRoutingModule { }

在用户下,我已经添加了诸如add和details之类的多组件,并且它具有路由功能,]

const routes: Routes = [

  {
    path: '',
    component: UserComponent,
    children: [
      { path: 'userlist', component: UserlistComponent },
      { path : 'adduser' , component: AdduserComponent},
      { path: ':id/Userdetails', component: UserdetailsComponent },
      { path: '', redirectTo: 'userlist', pathMatch: 'full' },
    ],
  }

];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class UserRoutingModule { }

我还添加了管理HTML和用户HTML当我单击用户链接时,出现错误错误:组件UserComponent不属于任何NgModule或模块尚未导入到您的模块中。并且没有打开我的路由中的错误是什么?

[大家好,我有带有组件的模块,我想在其中之一中添加组件,而这个模块有子页面,并且路由是const路由:Routes = [{path:''...

angular typescript angular-routing
1个回答
0
投票

错误仅表明UserComponent无法加载。

因此,首先检查UserComponent是否在UserModule的declarations

© www.soinside.com 2019 - 2024. All rights reserved.