【发布时间】:2020-09-14 13:40:26
【问题描述】:
我有两个模块,MapModule 和 LeftListModule。在 MapModule 里面我有 MapComponent,在 LeftListModule 里面有 LeftListContainerComponent。
我想要的是用LeftListContainerComponent变成MapComponent,如下
<p>map works!</p>
<app-left-list-container></app-left-list-container>
为此,我以这种方式配置了 LeftListModule
@NgModule({
declarations: [LeftListContainerComponent],
imports: [
CommonModule
],
exports:[LeftListContainerComponent]
})
export class LeftListModule { }
还有像这样的 MapModule
@NgModule({
declarations: [MapComponent, LeftListContainerComponent],
imports: [
CommonModule
]
})
export class MapModule { }
我在网上查了好几个结果,但我不明白问题出在哪里。
我收到这条消息:
map/map.component.html:2:1 中的错误 - 错误 NG8001:“app-left-list-container”不是已知元素: 1. 如果 'app-left-list-container' 是一个 Angular 组件,那么验证它是这个模块的一部分。 2. 如果“app-left-list-container”是一个 Web 组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到该组件的“@NgModule.schemas”以禁止显示此消息。
2 <app-left-list-container></app-left-list-container>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
map/map.component.ts:5:16
5 templateUrl: './map.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component MapComponent.
【问题讨论】:
标签: angular