@hapiness/ng-elements-loader
Version:
Service to load Angular Custom Elements inside Angular's applications
50 lines (49 loc) • 2.35 kB
TypeScript
import { Compiler, ComponentFactoryResolver, Injector } from '@angular/core';
import { Observable } from 'rxjs';
import { CustomElementComponentSelector, CustomElementModuleSelector } from './elements-registry';
export declare class ElementsLoaderService {
private _injector;
private _compiler;
private _componentFactoryResolver;
/** Map of unregistered custom elements and their respective module to load. */
private _elementsToLoad;
constructor(_injector: Injector, _compiler: Compiler, _componentFactoryResolver: ComponentFactoryResolver);
/**
* Queries the document element for any custom elements that have not yet been registered with
* the browser. Custom elements that are registered will be removed from the list of unregistered
* elements so that they will not be queried in subsequent calls. Compile the module and its component
* to be registered as custom elements.
* This function is used in JIT mode
*/
loadContainingCustomElements(data: CustomElementModuleSelector | CustomElementModuleSelector[]): Observable<any>;
/**
* Queries the document element for any custom elements that have not yet been registered with
* the browser. Custom elements that are registered will be removed from the list of unregistered
* elements so that they will not be queried in subsequent calls. Component will be registered as
* custom elements.
* This function is used in AOT mode
*/
registerContainingCustomElements(data: CustomElementComponentSelector | CustomElementComponentSelector[]): Observable<any>;
/**
* Main process to load custom elements
*/
private _customElements;
/**
* Registers the custom element defined on the WithCustomElement module factory
*/
private _register;
/**
* Create custom element for current selector
*/
private _createCustomElement;
/**
* Compile module and all components to retrieve the component and the injector for custom element creation.
* This function is only used in JIT mode.
*/
private _componentAndInjectorFromCompiledModule;
/**
* Resolve component to get module injector for custom element creation.
* This function is only used in AOT mode.
*/
private _componentAndInjectorFromComponentFactory;
}