(
component: Type<C>,
options: {
environmentInjector: EnvironmentInjector;
hostElement?: Element;
elementInjector?: Injector;
projectableNodes?: Node[][];
directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[];
bindings?: Binding[];
onError?: (error: Error, details: ErrorDetails) => void;
},
)
| 87 | * @publicApi |
| 88 | */ |
| 89 | export function createComponent<C>( |
| 90 | component: Type<C>, |
| 91 | options: { |
| 92 | environmentInjector: EnvironmentInjector; |
| 93 | hostElement?: Element; |
| 94 | elementInjector?: Injector; |
| 95 | projectableNodes?: Node[][]; |
| 96 | directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[]; |
| 97 | bindings?: Binding[]; |
| 98 | onError?: (error: Error, details: ErrorDetails) => void; |
| 99 | }, |
| 100 | ): ComponentRef<C> { |
| 101 | ngDevMode && assertComponentDef(component); |
| 102 | const componentDef = getComponentDef(component)!; |
| 103 | const elementInjector = options.elementInjector || getNullInjector(); |
| 104 | const factory = new ComponentFactory<C>(componentDef); |
| 105 | const componentRef = factory.create( |
| 106 | elementInjector, |
| 107 | options.projectableNodes, |
| 108 | options.hostElement, |
| 109 | options.environmentInjector, |
| 110 | options.directives, |
| 111 | options.bindings, |
| 112 | ); |
| 113 | if (options.onError) { |
| 114 | (componentRef.hostView as R3ViewRef<any>)._lView![ON_ERROR] = options.onError; |
| 115 | } |
| 116 | return componentRef; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * An interface that describes the subset of component metadata |
no test coverage detected