填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

ComponentFactory

可用来动态创建组件的工厂的基类。resolveComponentFactory() 实例化给定类型的组件的工厂。使用生成的 ComponentFactory.create() 方法创建该类型的组件。

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.

      
      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, ngModule?: NgModuleRef<any>): ComponentRef<C>
}
    

参见

属性

属性说明
abstract selector: string只读

组件的 HTML 选择器。

The component's HTML selector.

abstract componentType: Type<any>只读

工厂将创建的组件的类型。

The type of component the factory will create.

abstract ngContentSelectors: string[]只读

组件中所有元素的选择器。

Selector for allelements in the component.

abstract inputs: { propName: string; templateName: string; }[]只读

组件的输入。

The inputs of the component.

abstract outputs: { propName: string; templateName: string; }[]只读

组件的输出。

The outputs of the component.

方法

创建一个新组件。

Creates a new component.

      
      abstract create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: any, ngModule?: NgModuleRef<any>): ComponentRef<C>
    
参数
injector Injector
projectableNodes any[][]
可选. 默认值是 `undefined`.
rootSelectorOrNode any
可选. 默认值是 `undefined`.
ngModule NgModuleRef
可选. 默认值是 `undefined`.
返回值

ComponentRef<C>