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

Method createComponentRef

packages/core/testing/src/test_bed.ts:867–889  ·  view source on GitHub ↗
(
    type: Type<T>,
    tagName: string | null,
    renderer: TestComponentRenderer,
    rootTypeBindings?: Binding[],
    directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[],
    allowNonStandaloneDirectives?: boolean,
  )

Source from the content-addressed store, hash-verified

865 }
866
867 private createComponentRef<T>(
868 type: Type<T>,
869 tagName: string | null,
870 renderer: TestComponentRenderer,
871 rootTypeBindings?: Binding[],
872 directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[],
873 allowNonStandaloneDirectives?: boolean,
874 ) {
875 const rootElId = `root${_nextRootElementId++}`;
876 renderer.insertRootElement(rootElId, tagName ?? undefined);
877 const factory = new ComponentFactory(getComponentDef(type)!);
878
879 return factory.create(
880 Injector.NULL,
881 [],
882 `#${rootElId}`,
883 this.testModuleRef,
884 directives,
885 rootTypeBindings,
886 undefined,
887 allowNonStandaloneDirectives,
888 ) as ComponentRef<T>;
889 }
890
891 private destroyActiveFixtures(): void {
892 let errorCount = 0;

Callers 1

initMethod · 0.95

Calls 3

createMethod · 0.95
getComponentDefFunction · 0.70
insertRootElementMethod · 0.45

Tested by

no test coverage detected