MCPcopy
hub / github.com/angular/angular / createComponent

Function createComponent

packages/core/src/render3/component.ts:84–107  ·  view source on GitHub ↗
(
  component: Type<C>,
  options: {
    environmentInjector: EnvironmentInjector;
    hostElement?: Element;
    elementInjector?: Injector;
    projectableNodes?: Node[][];
    directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[];
    bindings?: Binding[];
  },
)

Source from the content-addressed store, hash-verified

82 * @publicApi
83 */
84export function createComponent<C>(
85 component: Type<C>,
86 options: {
87 environmentInjector: EnvironmentInjector;
88 hostElement?: Element;
89 elementInjector?: Injector;
90 projectableNodes?: Node[][];
91 directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[];
92 bindings?: Binding[];
93 },
94): ComponentRef<C> {
95 ngDevMode && assertComponentDef(component);
96 const componentDef = getComponentDef(component)!;
97 const elementInjector = options.elementInjector || getNullInjector();
98 const factory = new ComponentFactory<C>(componentDef);
99 return factory.create(
100 elementInjector,
101 options.projectableNodes,
102 options.hostElement,
103 options.environmentInjector,
104 options.directives,
105 options.bindings,
106 );
107}
108
109/**
110 * An interface that describes the subset of component metadata

Callers 11

ngAfterViewInitMethod · 0.90
ngAfterViewInitMethod · 0.90
createComponentMethod · 0.90
initializeComponentMethod · 0.90
createDomFunction · 0.90
showAsComponentMethod · 0.90
renderComponentMethod · 0.90

Calls 4

createMethod · 0.95
assertComponentDefFunction · 0.90
getComponentDefFunction · 0.90
getNullInjectorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…