【发布时间】:2018-05-16 19:33:35
【问题描述】:
你好,我正在尝试使用模态组件的延迟加载,所以我有一个这样的共享组件模块:
@NgModule({
declarations: [
AddNoteComponent,
EditNoteComponent
],
imports: [
IonicModule,
],
exports: [
AddNoteComponent,
EditNoteComponent
]
})
export class ComponentsModule {}
我想在 notes.ts 页面中使用它们,所以我将 componentsModule 类导入到 notes.module.ts,如下所示:
@NgModule({
declarations: [
NotesPage,
],
imports: [
IonicPageModule.forChild(NotesPage),
ComponentsModule,
],
})
export class NotesPageModule {}
所以在我的 notes.ts 中这个功能应该可以工作
addNoteModal() {
let noteModal = this.modalCtrl.create('AddNoteComponent', {
'mid': this.module.key
});
noteModal.present();
}
当我使用延迟加载时,这应该可以正常工作,
但 ionic 告诉我:
错误错误:未捕获(承诺中):无效链接:AddNoteComponent
这是我的环境:
Ionic Framework:3.9.2
离子应用脚本:3.1.2
角核心:5.0.1
Angular 编译器 CLI:5.0.1
节点:8.4.0
操作系统平台:Windows 10
导航平台:Win32
用户代理:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Mobile Safari/537.36
【问题讨论】:
-
我认为你的
AddNoteComponent应该是一个页面,即它应该有一个@IonicPage()装饰器。 -
是的,但我希望它只是一个组件,它在组件文件夹中
标签: angular typescript ionic2 ionic3