2

I am getting this Error:

No component factory found for TermsConditions while using angular2-rc6.

My route map is like this:

{
    path: '',
    component: TermsConditions
}
Karolis Koncevičius
  • 9,417
  • 9
  • 56
  • 89
Ashutosh Singh
  • 806
  • 1
  • 8
  • 20
  • Are you exporting `TermsConditions` component? – Madhu Ranjan Sep 09 '16 at 16:25
  • @MadhuRanjan: Can you explain me a bit more why this is required? @NgModule({ imports: [ RouterModule ], declarations : [ TermsConditionsComponent ] }) export default class TermsConditions {} – Ashutosh Singh Sep 09 '16 at 16:30
  • `declarations` is for using the component within the Module, and `exports` is for using it externally. You may read more about Modules [here](https://angular.io/docs/ts/latest/guide/ngmodule.html) and [FAQ here](https://angular.io/docs/ts/latest/cookbook/ngmodule-faq.html), they explain these concepts in depth. – Madhu Ranjan Sep 09 '16 at 16:36
  • @MadhuRanjan: Thanks but still getting the same after exporting the same. @NgModule({ declarations : [ TermsConditionsComponent ], exports: [ TermsConditionsComponent ] }) export default class TermsConditions {} – Ashutosh Singh Sep 09 '16 at 16:43
  • can you add more, on how you are activating the Route? and more code, May be create a Plunker reproducing the issue. – Madhu Ranjan Sep 09 '16 at 16:47
  • 1
    @Günter Zöchbauer this doesn't seem like a duplicate of the Q you referenced. That one is about dynamically loaded components, where as this is straight up module configuration. – Fiddles Nov 17 '16 at 07:00

2 Answers2

6

Thanks for your help. I got to know how to fix this issue.

No component factory found for TermsConditions.

  @NgModule({ 
          declarations : [ TermsConditionsComponent ]
        }) 
        export default class TermsConditions {}
  1. Import this module to your root module.

       @NgModule({ 
          declarations : [ AppComponent ],
          imports: [ BrowserModule, TermsConditions ],
          bootstrap: [ AppComponent ]
        }) 
        export default class AppModule {}
    
  2. use component in routing like.

    { 
      path : 'terms',
      component : TermsConditionsComponent
    }
    `
    

It means your module is not available in application scope that is why your component is not being bind to router.

Ashutosh Singh
  • 806
  • 1
  • 8
  • 20
2

You need to list the TermsConditions in both the declarations and entryComponents section.

https://stackoverflow.com/a/39376857

Community
  • 1
  • 1