MCPcopy Create free account
hub / github.com/angular/angular / create

Method create

packages/core/src/render3/component_ref.ts:266–315  ·  view source on GitHub ↗
(
    injector: Injector,
    projectableNodes?: any[][] | undefined,
    rootSelectorOrNode?: any,
    environmentInjector?: NgModuleRef<any> | EnvironmentInjector | undefined,
    directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[],
    componentBindings?: Binding[],
    hostElementNamespace?: string | null,
  )

Source from the content-addressed store, hash-verified

264 }
265
266 create(
267 injector: Injector,
268 projectableNodes?: any[][] | undefined,
269 rootSelectorOrNode?: any,
270 environmentInjector?: NgModuleRef<any> | EnvironmentInjector | undefined,
271 directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[],
272 componentBindings?: Binding[],
273 hostElementNamespace?: string | null,
274 ): AbstractComponentRef<T> {
275 profiler(ProfilerEvent.DynamicComponentStart);
276
277 const prevConsumer = setActiveConsumer(null);
278 try {
279 const cmpDef = this.componentDef;
280 ngDevMode && verifyNotAnOrphanComponent(cmpDef);
281 const rootViewInjector = createRootViewInjector(
282 cmpDef,
283 environmentInjector || this.ngModule,
284 injector,
285 );
286 const environment = createRootLViewEnvironment(rootViewInjector);
287 const tracingService = environment.tracingService;
288
289 if (tracingService && tracingService.componentCreate) {
290 return tracingService.componentCreate(getComponentName(cmpDef), () =>
291 this.createComponentRef(
292 environment,
293 rootViewInjector,
294 projectableNodes,
295 rootSelectorOrNode,
296 directives,
297 componentBindings,
298 hostElementNamespace,
299 ),
300 );
301 } else {
302 return this.createComponentRef(
303 environment,
304 rootViewInjector,
305 projectableNodes,
306 rootSelectorOrNode,
307 directives,
308 componentBindings,
309 hostElementNamespace,
310 );
311 }
312 } finally {
313 setActiveConsumer(prevConsumer);
314 }
315 }
316
317 private createComponentRef(
318 environment: LViewEnvironment,

Callers 3

createComponentMethod · 0.95
bootstrapImplMethod · 0.95
createComponentFunction · 0.95

Calls 8

createComponentRefMethod · 0.95
profilerFunction · 0.90
setActiveConsumerFunction · 0.90
getComponentNameFunction · 0.90
createRootViewInjectorFunction · 0.85
componentCreateMethod · 0.80

Tested by

no test coverage detected