Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular-Ionic-无法创建popover,组件注入错误_Angular_Typescript_Ionic Framework_Ionic3_Popover - Fatal编程技术网

Angular-Ionic-无法创建popover,组件注入错误

Angular-Ionic-无法创建popover,组件注入错误,angular,typescript,ionic-framework,ionic3,popover,Angular,Typescript,Ionic Framework,Ionic3,Popover,我正在尝试使用Ionic Framework v3显示一个Popover,我有一个包含列表组件的Ionic页面,在这个列表中,我有一个显示Popover的按钮。 因此,我在父页面中声明了我的popover组件,并在列表中创建了一个事件发射器,它将向父页面发送切换信息 但我得到了给定的错误: No component factory found for PopoverComponent. Did you add it to @NgModule.entryComponents? 页面模块的代码:

我正在尝试使用Ionic Framework v3显示一个Popover,我有一个包含列表组件的Ionic页面,在这个列表中,我有一个显示Popover的按钮。 因此,我在父页面中声明了我的popover组件,并在列表中创建了一个事件发射器,它将向父页面发送切换信息

但我得到了给定的错误:

No component factory found for PopoverComponent. Did you add it to @NgModule.entryComponents?
页面模块的代码:

@NgModule({
    declarations: [
        PopoverComponent
    ],
    imports: [
        IonicPageModule.forChild(MyCustomPage),
    ],
    entryComponents: [
        PopoverComponent
    ]
})
export class MyCustomModule {}
页面代码:

@Component({
    selector: 'my-custom-page',
    templateUrl: 'my-custom-page.html'
})
export class MyCustomPage {

    public constructor(public popoverCtrl: PopoverController) { }

    public toggleFilters() {
        const popover = this.popoverCtrl.create(PopoverComponent);
        popover.present();
    }
}
<my-custom-list (onFilterToggle)="toggleFilters()"></my-custom-list>
页面模板:

@Component({
    selector: 'my-custom-page',
    templateUrl: 'my-custom-page.html'
})
export class MyCustomPage {

    public constructor(public popoverCtrl: PopoverController) { }

    public toggleFilters() {
        const popover = this.popoverCtrl.create(PopoverComponent);
        popover.present();
    }
}
<my-custom-list (onFilterToggle)="toggleFilters()"></my-custom-list>

组件列表:

 @Component({
    selector: 'my-custom-list',
    templateUrl: 'my-custom-list.component.html'
 })
 export class MyCustomListComponent {

     @Output() onFilterToggle: EventEmitter<void> = new EventEmitter<void>();
     public showFilters() {
         this.onFilterToggle.emit();
     }
 }
@组件({
选择器:“我的自定义列表”,
templateUrl:'我的自定义列表.component.html'
})
导出类MyCustomListComponent{
@Output()onFilterToggle:EventEmitter=新的EventEmitter();
公共showFilters(){
this.onFilterToggle.emit();
}
}
组件模板:

 <button (click)="showFilters()">Test</button>
测试
流行密码:

@Component({
    selector: 'my-popover',
    template: '<p>Test</p>'
})
export class PopoverComponent {

    constructor(public viewCtrl: ViewController) {}

    close() {
        this.viewCtrl.dismiss();
    } 
}
@组件({
选择器:“我的popover”,
模板:“测试

” }) 导出类组件{ 构造函数(公共viewCtrl:ViewController){} 关闭(){ this.viewCtrl.disclose(); } }
我的所有页面都加载了一个共享模块,我尝试将其添加到此处,但仍然出现相同的错误,我尝试将其添加到列表组件、应用程序模块中的entryComponents,但仍然出现相同的错误

如果有人有主意的话。

那么, 我找到了一个解决方案,只需将IonicPage decorator添加到popover组件中。 创建一个模块来声明组件并删除声明和entrycomponents。 不要在另一个模块中加载该模块,爱奥尼亚将完成此操作。 所以popover的代码是:

@IonicPage({
    name: 'my-popover'
})
@Component({
    selector: 'my-popover',
    template: '<p>Test</p>'
})
export class PopoverComponent {

    constructor(public viewCtrl: ViewController) {}

    close() {
        this.viewCtrl.dismiss();
    } 
}
要调用popover,只需使用如下页面名称:

this.popoverCtrl.create('my-popover');

PopoverComponent是否有一个模块?组件是使用离子页面生成器创建的吗?