Error: Did you add it to @NgModule.entryComponents?

Hi,

So I was implementing @IonicPage Deep links on my Ionic 3 app and I came across this error :

Error: No component factory found for MeusCarrosPage. Did you add it to @NgModule.entryComponents?

I do have my MeusCarrosPage in entryComponents on meus-carros.module.ts :

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { MeusCarrosPage } from './meus-carros';

@NgModule({
  declarations: [
    MeusCarrosPage,
  ],
  imports: [
    IonicPageModule.forChild(MeusCarrosPage),
  ],
  entryComponents: [
    MeusCarrosPage,
  ],
})
export class MeusCarrosPageModule {}

And on my meus-carros.ts (MeusCarrosPage) I have the @IonicPage like this :

@IonicPage({
  name: 'carros',
  segment: 'carros'
})

So if I click on my button that redirects to the page MeusCarrosPage it shows the error above but if I change the link http://localhost:8100/ to http://localhost:8100/#/carros/ I can acsess to the page and data.

Any ideas why I’m getting this error ?

Thanks

1 Like

Hello,
do you load your page by eager loaded or lazy loaded?

Best regards, anna-liebt

@wowkaaps It seems that your page is lazy loaded, so the class reference will not work in navigation. Use a string instead:

this.navCtrl.push('carros');

2 Likes

Thanks @lucasbasquerotto for the solution :wink:

I just needed to change from this :
this.navCtrl.push(MeusCarrosPage);
to this :
this.navCtrl.push(‘carros’);

Hi,
Yep I changed to lazy loaded and I forgot that I needed to change the way I was calling the page.