cooper
cooper

Reputation: 437

No component factory found for Component - component already added to NgModule

I am getting this error when trying to open a modal component:

No component factory found for [ComponentName].
Did you add it to @NgModule.entryComponents?

The same modal is working elsewhere in the app so it has been added to the declarations and entryComponents sections of NgModule.

Is there anything else this message could mean?

Upvotes: 0

Views: 5669

Answers (1)

Yakov Fain
Yakov Fain

Reputation: 12378

Most likely you use dynamically loaded components like a dialog window. If this is the case, you need to list them in the entryComponents property of @NgModule, for example:

  entryComponents: [
    MyDialogComponent
  ]

You can see an example here: https://material.angular.io/components/dialog/overview

Upvotes: 4

Related Questions