UNPKG

ngx-dynamic-hooks

Version:

Automatically insert live Angular components into a dynamic string of content (based on their selector or any pattern of your choice) and render the result in the DOM.

63 lines (62 loc) 3.48 kB
import { EnvironmentInjector, EnvironmentProviders, Provider } from '@angular/core'; import { HookParserEntry } from './services/settings/parserEntry'; import { ParseOptions } from './services/settings/options'; import { HookIndex, ParseResult } from './interfacesPublic'; /** * Destroys all scopes and components created by standalone mode */ export declare const destroyAll: () => void; /** * Creates an isolated scope with its own providers that the dynamically-created components will then have access to. * * @param providers - A list of providers * @param parentScope - An optional parent scope created previously. Makes the parent providers also accessible to this scope. */ export declare const createProviders: (providers?: (Provider | EnvironmentProviders)[], parentScope?: ProvidersScope) => ProvidersScope; /** * A scope with an internal list of providers. All dynamic components created by its `parse` method will have access to them. */ export declare class ProvidersScope { private providers; private parentScope?; private _injector; get injector(): EnvironmentInjector | null; private _parseResults; get parseResults(): ParseResult[]; private _isDestroyed; get isDestroyed(): boolean; constructor(providers?: (Provider | EnvironmentProviders)[], parentScope?: ProvidersScope | undefined); /** * Parses content and loads components for all found hooks in standalone mode * * @param content - The content to parse * @param parsers - The parsers to use * @param context - An optional context object * @param options - An optional list of options * @param targetElement - An optional HTML element to use as the container for the loaded content. * @param targetHookIndex - An optional object to fill with the programmatic hook data. If none is provided, one is created and returned for you. * @param environmentInjector - An optional environmentInjector to use for the dynamically-loaded components. If none is provided, the default environmentInjector is used. */ parse(content: any, parsers: HookParserEntry[], context?: any, options?: ParseOptions | null, targetElement?: HTMLElement | null, targetHookIndex?: HookIndex, environmentInjector?: EnvironmentInjector | null): Promise<ParseResult>; /** * Returns the injector for this scope */ resolveInjector(): Promise<EnvironmentInjector>; /** * Destroys this scope and all of its created components */ destroy(): void; private checkIfDestroyed; } /** * Parses content and loads components for all found hooks in standalone mode * * @param content - The content to parse * @param parsers - The parsers to use * @param context - An optional context object * @param options - An optional list of options * @param targetElement - An optional HTML element to use as the container for the loaded content. * @param targetHookIndex - An optional object to fill with the programmatic hook data. If none is provided, one is created and returned for you. * @param environmentInjector - An optional environmentInjector to use for the dynamically-loaded components. If none is provided, the default environmentInjector is used. */ export declare const parse: (content: any, parsers: HookParserEntry[], context?: any, options?: ParseOptions | null, targetElement?: HTMLElement | null, targetHookIndex?: HookIndex, environmentInjector?: EnvironmentInjector | null) => Promise<ParseResult>;