Ionic 3延迟加载子页面

时间:2017-10-25 12:10:24

标签: angular ionic-framework ionic2 ionic3

我刚刚开始重构我的应用程序,尝试使用Ionic 3 Lazy Loading。

例如,我有一个页面EventPage,现在有一个EventPageModule

一切正常,用字符串引用导航到它。

但我无法做的就是从这个确切的页面打开一个子页面。

子页面为JoinersPage ...

JoinersPage:

// JoinersPage
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

@IonicPage()
@Component({
  selector: 'page-joiners',
  templateUrl: 'joiners.html',
})
export class JoinersPage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad JoinersPage');
  }

}

JoinersPageModule:

// JoinersPageModule
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { JoinersPage } from './joinersbis';

@NgModule({
  declarations: [
    JoinersPage,
  ],
  imports: [
    IonicPageModule.forChild(JoinersPage),
  ],
})
export class JoinersPageModule {}

EventPageModule:

// EventPageModule
import { NgModule } from '@angular/core';
import { MomentModule } from 'angular2-moment';
import { IonicPageModule } from 'ionic-angular';
import { IonicImageLoader } from 'ionic-image-loader';

import { DirectivesModule } from '../../directives/directives.module';
import { PipesModule } from '../../pipes/pipes.module';

import { EventPage } from './event';
import { EventChatComponent } from './event-chat/event-chat.component';

@NgModule({
  declarations: [
    EventPage,
    EventChatComponent
  ],
  imports: [
    IonicPageModule.forChild(EventPage),
    IonicImageLoader.forRoot(),
    DirectivesModule,
    MomentModule,
    PipesModule
  ],
  entryComponents: []
})
export class EventPageModule {}

当我点击应该打开JoinersPage的按钮时,使用以下代码this.navCtrl.push('JoinersPage');

我收到以下错误:

Error: No component factory found for JoinersPage. Did you add it to @NgModule.entryComponents?
Error: No component factory found for JoinersPage. Did you add it to @NgModule.entryComponents?
  1. 我认为Ionic 3 Lazy Loading的所有目的都是为了避免导入页面
  2. 我怎么能解决我的问题?

0 个答案:

没有答案