Angular 将共享组件导入惰性加载模块时不工作
我正在尝试在延迟加载的模块中加载一个共享组件。 单元我的惰性模块导入SharedModule如下: //LazyModule 在SharedModule中,我正在导入MenuComponent所需的角材质组件,MenuComponent作为共享组件导出: //共享模块 然后在我的LazyParentComponent中,我使用它来呈现MenuComponent,它包含在sharedModule中 但如果我开始这样做,我总是会遇到很多错误,比如无法绑定到“value”,因为它不是“mat select”的已知属性。或“mat toolbar”不是已知元素Angular 将共享组件导入惰性加载模块时不工作,angular,lazy-loading,angular-module,Angular,Lazy Loading,Angular Module,我正在尝试在延迟加载的模块中加载一个共享组件。 单元我的惰性模块导入SharedModule如下: //LazyModule 在SharedModule中,我正在导入MenuComponent所需的角材质组件,MenuComponent作为共享组件导出: //共享模块 然后在我的LazyParentComponent中,我使用它来呈现MenuComponent,它包含在sharedModule中 但如果我开始这样做,我总是会遇到很多错误,比如无法绑定到“value”,因为它不是“mat sele
但是,如果我不使用,而是直接使用MatButtonModule中的MatButtons,则它确实有效。您还需要在导入中包含所有材质模块: 共享模块
在共享模块内部,您是否将组件添加到声明和导出中?我没有将它们包括在描述中,但我只是看到,如果我将它们包括在导入中,一些错误就会消失。在app.module.t中也是这样做的。听起来不对。导入是针对模块的。哦,是的,我明白了。MenuComponent在声明和导出中。我说的是角材料模块
@NgModule({
imports: [
CommonModule,
SharedModule,
RouterModule.forChild(routes)
],
declarations: [
LazyParentComponent
]
})
@NgModule({
imports: [CommonModule],
declarations: [MenuComponent],
exports: [
MatButtonModule,
MatSelectModule,
MatInputModule,
MatOptionModule,
MatToolbarModule,
MenuComponent
]
})
@NgModule({
imports: [CommonModule,
MatButtonModule,
MatSelectModule,
MatInputModule,
MatOptionModule,
MatToolbarModule
],
declarations: [MenuComponent],
exports: [
MatButtonModule,
MatSelectModule,
MatInputModule,
MatOptionModule,
MatToolbarModule,
MenuComponent
]
})