Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hostElement option missing in viewContainer's createComponent() #62098

Closed as not planned
@ilyakonrad

Description

@ilyakonrad

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

Docs say there should be an option to define a host element for a dynamically rendered component.

In reality there's no such option (anymore?).

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-7jb7bw6y

Please provide the exception or error you saw

No overload matches this call.
  Overload 1 of 2, '(componentType: Type<EventTooltipComponent>, options?: { index?: number | undefined; injector?: Injector | undefined; ngModuleRef?: NgModuleRef<unknown> | undefined; environmentInjector?: EnvironmentInjector | ... 1 more ... | undefined; projectableNodes?: Node[][] | undefined; directives?: (Type<...> | DirectiveWithBindings<...>)[] | undefined; bindings?: Binding[] | undefined; } | undefined): ComponentRef<...>', gave the following error.
    Object literal may only specify known properties, and 'hostElement' does not exist in type '{ index?: number | undefined; injector?: Injector | undefined; ngModuleRef?: NgModuleRef<unknown> | undefined; environmentInjector?: EnvironmentInjector | NgModuleRef<...> | undefined; projectableNodes?: Node[][] | undefined; directives?: (Type<...> | DirectiveWithBindings<...>)[] | undefined; bindings?: Binding[] |...'.
  Overload 2 of 2, '(componentFactory: ComponentFactory<unknown>, index?: number | undefined, injector?: Injector | undefined, projectableNodes?: any[][] | undefined, environmentInjector?: EnvironmentInjector | ... 1 more ... | undefined, directives?: (Type<...> | DirectiveWithBindings<...>)[] | undefined, bindings?: Binding[] | undefined): ComponentRef<...>', gave the following error.
    Argument of type 'typeof EventTooltipComponent' is not assignable to parameter of type 'ComponentFactory<unknown>'.
      Type 'typeof EventTooltipComponent' is missing the following properties from type 'ComponentFactory<unknown>': selector, componentType, ngContentSelectors, inputs, and 2 more.ts(2769)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 20.0.2
Node: 22.15.1
Package Manager: yarn 1.22.22
OS: win32 x64

Angular: 20.0.3
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, material-moment-adapter
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2000.2
@angular-devkit/core         20.0.2
@angular-devkit/schematics   20.0.2
@angular/build               20.0.2
@angular/cli                 20.0.2
@angular/fire                18.0.1
@schematics/angular          20.0.2
rxjs                         7.8.2
typescript                   5.8.3
webpack                      5.99.9
zone.js                      0.15.1

Anything else?

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions