UNPKG

@docgeni/template

Version:

Docgeni - Angular Template Components

72 lines 3.34 kB
import { ApplicationRef, ComponentFactoryResolver, ComponentRef, Injector, ViewContainerRef } from '@angular/core'; export interface ComponentType<T> { new (...args: any[]): T; } export interface PortalOutlet { /** Attaches a portal to this outlet. */ attach(portal: Portal<any>): any; /** Detaches the currently attached portal from this outlet. */ detach(): any; /** Performs cleanup before the outlet is destroyed. */ dispose(): void; /** Whether there is currently a portal attached to this outlet. */ hasAttached(): boolean; } export declare abstract class Portal<T> { private _attachedHost; /** Attach this portal to a host. */ attach(host: PortalOutlet): T; /** Detach this portal from its host */ detach(): void; /** Whether this portal is attached to a host. */ get isAttached(): boolean; /** * Sets the PortalOutlet reference without performing `attach()`. This is used directly by * the PortalOutlet when it is performing an `attach()` or `detach()`. */ setAttachedHost(host: PortalOutlet | null): void; } /** * A `ComponentPortal` is a portal that instantiates some Component upon attachment. */ export declare class ComponentPortal<T> extends Portal<ComponentRef<T>> { /** The type of the component that will be instantiated for attachment. */ component: ComponentType<T>; /** * [Optional] Where the attached component should live in Angular's *logical* component tree. * This is different from where the component *renders*, which is determined by the PortalOutlet. * The origin is necessary when the host is outside of the Angular application context. */ viewContainerRef?: ViewContainerRef | null; /** [Optional] Injector used for the instantiation of the component. */ injector?: Injector | null; /** * Alternate `ComponentFactoryResolver` to use when resolving the associated component. * Defaults to using the resolver from the outlet that the portal is attached to. */ componentFactoryResolver?: ComponentFactoryResolver | null; constructor(component: ComponentType<T>, viewContainerRef?: ViewContainerRef | null, injector?: Injector | null, componentFactoryResolver?: ComponentFactoryResolver | null); } export declare class DomPortalOutlet implements PortalOutlet { protected outletElement: Element; protected componentFactoryResolver: ComponentFactoryResolver; protected appRef: ApplicationRef; protected defaultInjector: Injector; protected projectableNodes: any[][]; private disposeFn; private isDisposed; protected attachedPortal: Portal<unknown> | null; constructor(outletElement: Element, componentFactoryResolver: ComponentFactoryResolver, appRef: ApplicationRef, defaultInjector: Injector, projectableNodes: any[][]); attach<T>(portal: ComponentPortal<T>, replace?: boolean): ComponentRef<T>; hasAttached(): boolean; /** Detaches a previously attached portal. */ detach(): void; /** Permanently dispose of this portal host. */ dispose(): void; /** @docs-private */ setDisposeFn(fn: () => void): void; private invokeDisposeFn; /** Gets the root HTMLElement for an instantiated component. */ private getComponentRootNode; } //# sourceMappingURL=dom-portal-outlet.d.ts.map