子路由组件看不到的可重用组件
Reusable component not seen by children routes components
我有 2 条懒加载路由:
const routes: Routes = [
{
path: '',
redirectTo: 'login',
pathMatch: 'full'
},
{
path: 'login',
loadChildren: () => import('./login/login.module').then(m => m.LoginModule)
},
{
path: 'dashboard',
loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule)
}
];
仪表板路由有子路由。
const routes: Routes = [
{
path: '',
component: DashboardComponent,
children: [
{
path: '',
component: HomeComponent
},
{
path: 'usuarios',
component: UsersComponent
}
]
}
]
我创建了一个工具栏可重用组件,我想在仪表板路由器出口上渲染它,但是当我导航到仪表板模块的子路由时,angular 编译器说应用程序工具栏不是组件。
我已经在 Dashboard 模块上添加了组件并在 AppModule 上也进行了尝试,但我得到了相同的结果。
我错过了什么吗?
我相信这是 Angular 中延迟加载路由的常见问题。尽管像您一样以编程方式指定 LoadChildren
很方便,但您必须改用字符串,a la
loadChildren: './login/login.module#LoginModule',
我有 2 条懒加载路由:
const routes: Routes = [
{
path: '',
redirectTo: 'login',
pathMatch: 'full'
},
{
path: 'login',
loadChildren: () => import('./login/login.module').then(m => m.LoginModule)
},
{
path: 'dashboard',
loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule)
}
];
仪表板路由有子路由。
const routes: Routes = [
{
path: '',
component: DashboardComponent,
children: [
{
path: '',
component: HomeComponent
},
{
path: 'usuarios',
component: UsersComponent
}
]
}
]
我创建了一个工具栏可重用组件,我想在仪表板路由器出口上渲染它,但是当我导航到仪表板模块的子路由时,angular 编译器说应用程序工具栏不是组件。
我已经在 Dashboard 模块上添加了组件并在 AppModule 上也进行了尝试,但我得到了相同的结果。 我错过了什么吗?
我相信这是 Angular 中延迟加载路由的常见问题。尽管像您一样以编程方式指定 LoadChildren
很方便,但您必须改用字符串,a la
loadChildren: './login/login.module#LoginModule',