Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

ComponentFactory

Base class for a factory that can create a component dynamically. Instantiate a factory for a given type of component with resolveComponentFactory(). Use the resulting ComponentFactory.create() method to create a component of that type.

Deprecated: Angular no longer requires Component factories. Please use other APIs where Component class can be used directly.

      
      abstract class ComponentFactory<C> {
  abstract selector: string
  abstract componentType: Type<any>
  abstract ngContentSelectors: string[]
  abstract inputs: {...}
  abstract outputs: {...}
abstract create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: any, environmentInjector?: EnvironmentInjector | NgModuleRef<any>): ComponentRef<C> }

Properties

Property Description
abstract selector: string Read-Only

The component's HTML selector.

abstract componentType: Type<any> Read-Only

The type of component the factory will create.

abstract ngContentSelectors: string[] Read-Only

Selector for all elements in the component.

abstract inputs: { propName: string; templateName: string; transform?: (value: any) => any; }[] Read-Only

The inputs of the component.

abstract outputs: { propName: string; templateName: string; }[] Read-Only

The outputs of the component.

Methods

Creates a new component.

      
      abstract create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: any, environmentInjector?: EnvironmentInjector | NgModuleRef<any>): ComponentRef<C>
    
Parameters
injector Injector
projectableNodes any[][]

Optional. Default is undefined.

rootSelectorOrNode any

Optional. Default is undefined.

environmentInjector EnvironmentInjector | NgModuleRef<any>

Optional. Default is undefined.

Returns

ComponentRef<C>