X Tutup
Skip to content

DynamicComponentLoader.loadIntoExistingLocation should create a host element #2339

@tbosch

Description

@tbosch

Right now, Angular has 2 ways of loading dynamic components:

  1. Using a @Component that does not have a view and dynamically loads another component onto the same element including the view of that component
  2. Using a regular @Directive that creates a host view via a ViewContainer (i.e. a View that contains the host element of the component)

Option 1) has the following downsides:

  • it allows having 2 component instances on the same element, including possible 2 app injectors on it, which can have unexpected corner cases. It can also lead to a component without a view at all.
  • it does not handle animations, as we can't animate adding a shadow root. I.e. if a user wants to use option 1) + animations, he needs to use a ViewContainer any ways
  • the only customer (GT) for which we designed it actually needs the host element

We should change option 1) into also creating a host view but inserting it as a child of a given ElementRef.

Note that this would also allow to remove 1 method from the Compiler, leaving only one public method.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    X Tutup