Cur*_*ngs 7 uipopovercontroller ng-modules ionic3 angular
我想在我的主页上创建一个popover.所以我创建了以下功能..
public presentPopover(myEvent) {
let popover = this.popoverCtrl.create(TestComponent);
popover.present({
ev: myEvent
});
}
Run Code Online (Sandbox Code Playgroud)
在我的homepage.module.ts中我添加了testComponent作为入口组件.
import { TestModule } from './../../components/test/test.module';
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { HomePage } from './home';
import { TestComponent } from './../../components/test/test';
@NgModule({
declarations: [
HomePage,
],
imports: [
TestModule,
IonicPageModule.forChild(HomePage),
],
entryComponents: [
TestComponent,
]
})
Run Code Online (Sandbox Code Playgroud)
但是当我点击弹出按钮时,我仍然会收到此错误.
ERROR Error: Uncaught (in promise): Error: No component factory found for TestComponent. Did you add it to @NgModule.entryComponents?
Error: No component factory found for TestComponent. Did you add it to @NgModule.entryComponents?
at noComponentFactoryError (core.js:3786)
at CodegenComponentFactoryResolver.resolveComponentFactory (core.js:3850)
at PopoverCmp._load (popover-component.js:41)
at PopoverCmp.ionViewPreLoad (popover-component.js:33)
Run Code Online (Sandbox Code Playgroud)
我很困惑,为什么要将其添加到条目组件?
aru*_*mar 10
您需要将动态创建的组件添加到@NgModule中的条目组件中
@NgModule({
...
declarations: [
...
Name of your component,
],
entryComponents: [
...
Name of your component,
]
})
Run Code Online (Sandbox Code Playgroud)
注意:在某些情况下,延迟加载模块下的入口组件将无法工作,因为解决方法将它们放在app.module(root)中
| 归档时间: |
|
| 查看次数: |
13961 次 |
| 最近记录: |