【发布时间】:2020-12-29 07:50:48
【问题描述】:
我有三个组件(NavbarComponent、IndexComponent、PoweredComponent)所以我使用延迟加载我需要在多组件中使用组件,我不不知道如何声明组件以在惰性模块中使用它。我将向您展示不同文件的一些相关部分:
- 导航栏组件
navbar.module.ts
declarations: [NavbarComponent],
imports: [
CommonModule
],
exports: [NavbarComponent]
})
- 索引组件
Index.module.ts
declarations: [IndexComponent ,NavbarComponent],
imports: [
CommonModule,
IndexRoutingModule,
],
})
index.component.html
<app-navbar></app-navbar>
<div>...</div>
在索引显示导航栏
- 供电组件
powered.module.ts
@NgModule({
declarations: [PoweredComponent,NavbarComponent],
imports: [
CommonModule,
PoweredRoutingModule,
],
})
powered.component.html
<app-navbar></app-navbar>
<div>...</div>
在powered.component.html没有显示导航栏
issue
<app-navbar></app-navbar>not dispaly in multi components can show jsut in index components
请帮帮我???
感谢阅读!!!
【问题讨论】:
标签: angular angular-components angular-module