Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No component factory found for" Error When trying to push from one Page to another

Tags:

I get an error when trying to push from one page to another. When I try to push to same page, it won't give that error. Only i get error when pushing from one page to another. 'setRoot()' also not giving an error.

this.navCtrl.push( Page7 ); 

I have added the Page7 to app.module.ts.

import { NgModule } from '@angular/core'; import { IonicApp, IonicModule } from 'ionic-angular'; import { MyApp } from './app.component';  import { Page1 } from '../pages/page1/page1'; import { Page2 } from '../pages/page2/page2'; import { Page3 } from '../pages/page3/page3'; import { Page4 } from '../pages/page4/page4'; import { Page5 } from '../pages/page5/page5'; import { Page6 } from '../pages/page6/page6'; import { Page7 } from '../pages/page7/page7';  @NgModule({ declarations: [ MyApp, Page1, Page2, Page3, Page4, Page5, Page6, Page7 ], imports: [ IonicModule.forRoot(MyApp) ], bootstrap: [IonicApp], entryComponents: [ MyApp, Page1, Page2, Page3, Page4, Page5, Page6, Page7 ], providers: [] })  export class AppModule {} 

This is a ionic 2 Application. It Gives this error.

EXCEPTION: Error in ./Page6 class Page6 - inline template:21:56 caused by: No component factory found for Page7 

console error

like image 602
Chamil Kandamby Avatar asked Oct 05 '16 10:10

Chamil Kandamby


1 Answers

I found the solution. You have to add the page that you are trying to push, to the parent directory. That should also be included in to the @NgModule also.

import {ApiServices} from '../../providers/api-services'; import { Visualizer } from '../Page7/Page7';  @Component({   selector: 'page-page6',   templateUrl: 'page6.html',   providers: [ ApiServices ],   entryComponents:[ Page7 ] })  export class Page6 {     tapped(event, id ) {       this.navCtrl.push( Page7,{        id: id       });     } }       
like image 121
Chamil Kandamby Avatar answered Oct 15 '22 16:10

Chamil Kandamby