ng-messages2
Version:
Angular version of ng-message
68 lines (67 loc) • 2.69 kB
TypeScript
/// <reference types="es6-shim" />
import { TemplateRef, ViewContainerRef, ElementRef } from '@angular/core';
/**
* A `Portal` is something that you want to render somewhere else.
* It can be attach to / detached from a `PortalHost`.
*/
export declare abstract class Portal<T> {
private _attachedHost;
/** Attach this portal to a host. */
attach(host: PortalHost): T;
/** Detach this portal from its host */
detach(): void;
/** Whether this portal is attached to a host. */
readonly isAttached: boolean;
/**
* Sets the PortalHost reference without performing `attach()`. This is used directly by
* the PortalHost when it is performing an `attach()` or `detach()`.
*/
setAttachedHost(host: PortalHost): void;
}
/**
* A `TemplatePortal` is a portal that represents some embedded template (TemplateRef).
*/
export declare class TemplatePortal extends Portal<Map<string, any>> {
/** The embedded template that will be used to instantiate an embedded View in the host. */
templateRef: TemplateRef<any>;
/** Reference to the ViewContainer into which the template will be stamped out. */
viewContainerRef: ViewContainerRef;
/**
* Additional locals for the instantiated embedded view.
* These locals can be seen as "exports" for the template, such as how ngFor has
* index / event / odd.
* See https://angular.io/docs/ts/latest/api/core/EmbeddedViewRef-class.html
*/
locals: Map<string, any>;
constructor(template: TemplateRef<any>, viewContainerRef: ViewContainerRef);
readonly origin: ElementRef;
attach(host: PortalHost, locals?: Map<string, any>): Map<string, any>;
detach(): void;
}
/**
* A `PortalHost` is an space that can contain a single `Portal`.
*/
export interface PortalHost {
attach(portal: Portal<any>): any;
detach(): any;
dispose(): void;
hasAttached(): boolean;
}
/**
* Partial implementation of PortalHost that only deals with attaching either a TemplatePortal.
*/
export declare abstract class BasePortalHost implements PortalHost {
/** The portal currently attached to the host. */
private _attachedPortal;
/** A function that will permanently dispose this host. */
private _disposeFn;
/** Whether this host has already been permanently disposed. */
private _isDisposed;
/** Whether this host has an attached portal. */
hasAttached(): boolean;
attach(portal: Portal<any>): any;
abstract attachTemplatePortal(portal: TemplatePortal): Map<string, any>;
detach(): void;
dispose(): void;
setDisposeFn(fn: () => void): void;
}