我是Angular的新手,很抱歉提出愚蠢的问题。我创建了一个项目,并且想在其中使用共享组件,但是出现错误...
有人有解决方案吗?
ProjectName.module.ts
...
import { SharedModuleModule } from 'src/app/shared/shared-module.module';
@NgModule({
...
imports: [
BrowserModule,
SharedModuleModule
],
.......
})
错误
........ src/app/app.config.ts:5:1: Error encountered in metadata generated for exported symbol 'AppConfig':
......... src/app/app.config.ts:7:12: Metadata collected contains an error that will be reported at runtime: Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler.
文件树
projects
- ProjectName
- src
- lib
- components
- ProjectName.module.ts
src
- app
- shared
- components
- shared.module.ts
如果要使用导入模块中的共享组件,则必须确保导入模块正在导出该组件。
@NgModule({
declarations: [
SharedComponent
],
exports: [
SharedComponent
]
})
export class AppSharedModule { }