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

Method create

packages/core/src/render3/component_ref.ts:253–299  ·  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

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