【问题标题】:Error: No component factory found for BarChartComponent in angular 4错误:在角度 4 中找不到 BarChartComponent 的组件工厂
【发布时间】:2018-02-12 12:03:31
【问题描述】:

未捕获(承诺):错误:未找到 BarChartComponent 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?

ngOnInit() {

this.sidenavdropdownservice.getJson()
  .subscribe(data => {
    this.list = data;

    for(let i of data) {
      for(let j of i.subMenu) {
        for(let a in j.url) {
          console.log('path : ' + j.url[a].path)
          //this.router.config.push({path : j.url[a].path , component : j.url[a].component});
          this.ROUTES.push({path : j.url[a].path , component : j.url[a].component});
          this.router.resetConfig(this.ROUTES);
        }
      }
    }
    console.log(data);
  }, err => {
    console.log(err);
  });

}

【问题讨论】:

  • 请添加您的代码
  • 你添加 BarChartComponent 到 @NgModule.entryComponents 了吗?
  • 是的,我在 app.module.ts 中添加了它

标签: angular angular4-router


【解决方案1】:

检查您的 app.module.ts。

你应该把你的页面放在@NgMogule 中。

 @NgModule({
      declarations: [
           YourPage,
               ],
    entryComponents: [
    YourPage,
              ]

我有同样的错误,在我的情况下是那个问题。

【讨论】:

    猜你喜欢
    • 2019-08-10
    • 2019-03-02
    • 1970-01-01
    • 2020-07-01
    • 2019-07-10
    • 1970-01-01
    • 2012-03-05
    • 2017-02-15
    • 2017-10-14
    相关资源
    最近更新 更多