【发布时间】:2020-08-27 10:05:56
【问题描述】:
我正在尝试创建一个简单的功能模块,但我的导入失败了,我不知道为什么。以下是我的功能模块的重要部分
@NgModule({
declarations: [
ProducerLookupComponent,
ProducerAddComponent
]
exports: [
ProducerLookupComponent,
ProducerAddComponent
]
})
export class ProducerModule { }
我在我的应用模块中导入了 ProducerModule。然后我想使用 ProducerLookupComponent 和 ProducerAddComponent 作为对话框的模板,所以我不会在任何地方的另一个 html 模板中添加它们的选择器。这是唯一与创建功能模块的基本教程不同的地方。我创建了其他功能模块,我只是通过它们的选择器使用组件就好了。
所以在我创建对话框的 ts 文件中,我有这样的代码
import { ProducerLookupComponent, ProducerAddComponent} from '../producer/producer.module';
我明白了
ERROR in src/app/application-initiation-fio/application-initiation-fio.component.ts:8:10 - error TS2459: Module '"D:/code/ade/client/src/app/producer/producer.module"' declares 'ProducerLookupComponent' locally, but it is not exported.
请注意,我可以像这样在我的生产者模块中添加导出语句来“修复”错误
export{ ProducerLookupComponent } from './producer-lookup/producer-lookup.component';
export{ ProducerAddComponent } from './producer-add/producer-add.component';
但这似乎是多余的。
任何帮助将不胜感激,谢谢!
【问题讨论】:
-
是的。不过好像不是同一个问题。反正不完全一样。
-
你把你的对话框组件作为入口组件了吗?
标签: angular