Jignesh Mistry
Jignesh Mistry

Reputation: 2479

Angular 6 Application Productions build gets successfully but on load throws error No component factory found for t

I am building a application where when i run the below command it gets generated successfully & also dist folder is created.

ng build --prod --base-href /ICS/

But when i run the application it shows me the login screen as well but when I log in i throws the below error.

Uncaught (in promise): Error: No component factory found for t. Did you add it to @NgModule.entryComponents?
Error: No component factory found for t. Did you add it to @NgModule.entryComponents?

I cannot understand what it this "t" coming from ?

Upvotes: 2

Views: 399

Answers (1)

Mahmoud Fawzy
Mahmoud Fawzy

Reputation: 1675

you have some components injected or used in other components so if you are using lazy loading modules then you need to add it to entrycomponents array in the parent lazy loaded module, if not then you need to add it to app module.

also make sure that all entry components added to declaration array.

@NgModule({
  declarations: [
    AppComponent,
    YourComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpClientModule,
    AppRoutingModule
  ],
  providers: [],
  entryComponents: [YourComponent]
  bootstrap: [AppComponent]
})

if your entry component in another module, you should export it there first to use it.

exports: [ YourComponent ]

that issue happens alot specially when you use components as popups or dialogs

Upvotes: 2

Related Questions