MatheusEdnei
MatheusEdnei

Reputation: 104

Ionic 4 page navigation

I am trying to create an application using ionic 4. Initially, I need to navigate between one screen and another (go from page 1 to page 2). But, the following error always pops up for me:

Uncaught (in promise): Error: No component factory found for Page2. Did you add it to @NgModule.entryComponents?
Error: No component factory found for Page2. Did you add it to @NgModule.entryComponents?

My page1.html:

<ion-header>
  <ion-navbar>
    <button ion-button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
    <ion-title>Page One</ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <ion-label id="textView">Oi, Fulano!</ion-label>
  <button (click)='outraPagina();' id="btnTrocar">Trocar usuário</button>
</ion-content>

My page1.ts:

import { Component } from '@angular/core';
import { IonicPage, NavController } from 'ionic-angular';
import { Page2 } from '../page2/page2'

@IonicPage()
@Component({
  selector: 'page-page1',
  templateUrl: 'page1.html'
})
export class Page1 {
  constructor(public navCtrl: NavController) {

  }

  outraPagina() {
    this.navCtrl.push(Page2, {});
  }

}

Any ideas on how to solve? Thank you.

Upvotes: 0

Views: 441

Answers (1)

parrycima
parrycima

Reputation: 945

You need to add page2 inside app.module.ts

  declarations: [
    AppComponent,
    page2
  ],
  entryComponents: [page2],

Upvotes: 1

Related Questions