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

Method create

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

Source from the content-addressed store, hash-verified

256 }
257
258 create(
259 injector: Injector,
260 projectableNodes?: any[][] | undefined,
261 rootSelectorOrNode?: any,
262 environmentInjector?: NgModuleRef<any> | EnvironmentInjector | undefined,
263 directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[],
264 componentBindings?: Binding[],
265 ): AbstractComponentRef<T> {
266 profiler(ProfilerEvent.DynamicComponentStart);
267
268 const prevConsumer = setActiveConsumer(null);
269 try {
270 const cmpDef = this.componentDef;
271 ngDevMode && verifyNotAnOrphanComponent(cmpDef);
272 const rootViewInjector = createRootViewInjector(
273 cmpDef,
274 environmentInjector || this.ngModule,
275 injector,
276 );
277 const environment = createRootLViewEnvironment(rootViewInjector);
278 const tracingService = environment.tracingService;
279
280 if (tracingService && tracingService.componentCreate) {
281 return tracingService.componentCreate(getComponentName(cmpDef), () =>
282 this.createComponentRef(
283 environment,
284 rootViewInjector,
285 projectableNodes,
286 rootSelectorOrNode,
287 directives,
288 componentBindings,
289 ),
290 );
291 } else {
292 return this.createComponentRef(
293 environment,
294 rootViewInjector,
295 projectableNodes,
296 rootSelectorOrNode,
297 directives,
298 componentBindings,
299 );
300 }
301 } finally {
302 setActiveConsumer(prevConsumer);
303 }
304 }
305
306 private createComponentRef(
307 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