填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫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>