我有一个分为以下模块的应用程序:
/app /core /admin /authentication /wst
管理员是一个带有侧栏的复杂模块,身份验证只是一个登录屏幕。我只想在管理模块处于活动状态时加载侧栏,而不想在app.component.html中包含*ngIf。
如何使这样的配置正常工作? stackblitz that shows my problem .
如果您希望在AdminComponent中使用ProfileComponent,AdminModule的路由应类似于:
const routes: Routes = [ { path: '', component: AdminComponent, children: [ { path: 'profile', component: ProfileComponent } ] }, ]
还有一些构建错误需要首先修复:
导入AdminRoutingModule而不是AdminModule中的RoutingModule。
ProfileComponent应该在AdminModule中声明或导入。
然后 /admin/profile 应显示带有菜单和配置文件的AdminComponent。如果你想的话 /admin
/admin/profile
/admin