“没有为"找到组件工厂尝试从一个页面推送到另一个页面时出错 [英] "No component factory found for" Error When trying to push from one Page to another
本文介绍了“没有为"找到组件工厂尝试从一个页面推送到另一个页面时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试从一页推送到另一页时出现错误.当我尝试推送到同一页面时,它不会给出该错误.从一页推送到另一页时,只有我会出错.'setRoot()' 也没有给出错误.
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 );
我已将 Page7 添加到 app.module.ts.
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 {}
这是一个离子 2 应用程序.它给出了这个错误.
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
推荐答案
我找到了解决方案.您必须将尝试推送的页面添加到父目录.这也应该包含在@NgModule 中.
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
});
}
}
这篇关于“没有为"找到组件工厂尝试从一个页面推送到另一个页面时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文