Skip to content

Allow componentFactoryResolver to be passed to MatDialog.open #16431

Closed
@scriby

Description

@scriby

Feature Description

The portal made by MatDialog always defaults to the root component factory resolver, which means any dynamically rendered components must be registered in the root component. This seems to cause a lot of confusion (#1491, #8473) and lots of stack overflow posts.

Having to declare these components in the root module is bad for modularity and code splitting. It seems that if we could provide the component factory resolver to the portal (similar to how the viewContainerRef is provided for the injector), then it would be possible to define the dynamically created entryComponents in modules closer to where they're used.

See

const contentRef = dialogContainer.attachComponentPortal<T>(
new ComponentPortal(componentOrTemplateRef, undefined, injector));
. This code path is both not using the passed in viewContainerRef, and it also doesn't provide a componentFactoryResolver to the portal.

Use Case

Support lazy loaded dialog components, allowing for better code modularity and more precise code splitting.

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functionsfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions