【发布时间】:2021-11-24 03:27:47
【问题描述】:
我有一个名为“test”的简单 Angular 库项目,其中只有一个组件显示材质图标。我已经构建了它(ng build test)
我的库模块:
@NgModule({
declarations: [
TestComponent
],
imports: [
],
exports: [
TestComponent
]
})
export class TestModule { }
我想在我的 Angular 应用程序中测试这个库。我在 app.module.ts 中添加了库:
import {TestComponent} from '../../dist/test'
和
@NgModule({
imports: [
TestComponent,
我正在使用这个组件,但不幸的是我在 ng serve 命令期间遇到了错误:
Error: ../../dist/test/lib/test.component.d.ts:3:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
This likely means that the dependency which declares TestComponent has not been processed correctly by ngcc.
【问题讨论】:
-
您应该将 TestModule 导入 AppModule,而不是 TestComponent
标签: angular angular-library angular12