API reference for Angular CDK portal
import {PortalModule} from '@angular/cdk/portal';
Directives
CdkPortal
extends
TemplatePortal
Directive version of a TemplatePortal
. Because the directive is a TemplatePortal,
the directive instance itself can be attached to a host, enabling declarative use of portals.
Selector: [cdkPortal]
Exported as: cdkPortalProperties
Name | Description |
---|---|
|
Contextual data to be passed in to the embedded view. |
|
The injector to use for the embedded view. |
|
Whether this portal is attached to a host. |
|
|
|
The embedded template that will be used to instantiate an embedded View in the host. |
|
Reference to the ViewContainer into which the template will be stamped out. |
Methods
attach | |
---|---|
Attach the portal to the provided |
|
Parameters | |
host PortalOutlet
|
|
context C = this.context
|
|
Returns | |
EmbeddedViewRef<C>
|
|
detach |
---|
setAttachedHost | |
---|---|
Sets the PortalOutlet reference without performing |
|
Parameters | |
host PortalOutlet
|
|
TemplatePortalDirective
extends
CdkPortal
Selector: [cdk-portal] [portal]
Exported as: cdkPortalProperties
Name | Description |
---|---|
|
Contextual data to be passed in to the embedded view. |
|
The injector to use for the embedded view. |
|
Whether this portal is attached to a host. |
|
|
|
The embedded template that will be used to instantiate an embedded View in the host. |
|
Reference to the ViewContainer into which the template will be stamped out. |
Methods
attach | |
---|---|
Attach the portal to the provided |
|
Parameters | |
host PortalOutlet
|
|
context C = this.context
|
|
Returns | |
EmbeddedViewRef<C>
|
|
detach |
---|
setAttachedHost | |
---|---|
Sets the PortalOutlet reference without performing |
|
Parameters | |
host PortalOutlet
|
|
CdkPortalOutlet
extends
BasePortalOutlet
Directive version of a PortalOutlet. Because the directive is a PortalOutlet, portals can be directly attached to it, enabling declarative use.
Usage:
<ng-template [cdkPortalOutlet]="greeting"></ng-template>
Selector: [cdkPortalOutlet]
Exported as: cdkPortalOutletProperties
Name | Description |
---|---|
@Input('cdkPortalOutlet')
|
Portal associated with the Portal outlet. |
@Output()
|
Emits when a portal is attached to the outlet. |
|
Component or view reference that is attached to the portal. |
Deprecated
|
Attaches the given DomPortal to this PortalHost by moving all of the portal content into it. |
Methods
attach | |
---|---|
Parameters | |
portal ComponentPortal<T>
|
|
Returns | |
ComponentRef<T>
|
|
attach | |
---|---|
Parameters | |
portal TemplatePortal<T>
|
|
Returns | |
EmbeddedViewRef<T>
|
|
attach | |
---|---|
Parameters | |
portal any
|
|
Returns | |
any
|
|
attachComponentPortal | |
---|---|
Attach the given ComponentPortal to this PortalOutlet. |
|
Parameters | |
portal ComponentPortal<T>
|
Portal to be attached to the portal outlet. |
Returns | |
ComponentRef<T>
|
Reference to the created component. |
attachTemplatePortal | |
---|---|
Attach the given TemplatePortal to this PortalHost as an embedded View. |
|
Parameters | |
portal TemplatePortal<C>
|
Portal to be attached. |
Returns | |
EmbeddedViewRef<C>
|
Reference to the created embedded view. |
detach | |
---|---|
Detaches a previously attached portal. |
dispose | |
---|---|
Permanently dispose of this portal host. |
hasAttached | |
---|---|
Whether this host has an attached portal. |
|
Returns | |
boolean
|
|
PortalHostDirective
extends
CdkPortalOutlet
Selector: [cdkPortalHost] [portalHost]
Exported as: cdkPortalHostProperties
Name | Description |
---|---|
@Input(cdkPortalHost)
|
Portal associated with the Portal outlet. |
@Output()
|
Emits when a portal is attached to the outlet. |
|
Component or view reference that is attached to the portal. |
Deprecated
|
Attaches the given DomPortal to this PortalHost by moving all of the portal content into it. |
Methods
attach | |
---|---|
Parameters | |
portal ComponentPortal<T>
|
|
Returns | |
ComponentRef<T>
|
|
attach | |
---|---|
Parameters | |
portal TemplatePortal<T>
|
|
Returns | |
EmbeddedViewRef<T>
|
|
attach | |
---|---|
Parameters | |
portal any
|
|
Returns | |
any
|
|
attachComponentPortal | |
---|---|
Attach the given ComponentPortal to this PortalOutlet. |
|
Parameters | |
portal ComponentPortal<T>
|
Portal to be attached to the portal outlet. |
Returns | |
ComponentRef<T>
|
Reference to the created component. |
attachTemplatePortal | |
---|---|
Attach the given TemplatePortal to this PortalHost as an embedded View. |
|
Parameters | |
portal TemplatePortal<C>
|
Portal to be attached. |
Returns | |
EmbeddedViewRef<C>
|
Reference to the created embedded view. |
detach | |
---|---|
Detaches a previously attached portal. |
dispose | |
---|---|
Permanently dispose of this portal host. |
hasAttached | |
---|---|
Whether this host has an attached portal. |
|
Returns | |
boolean
|
|
Classes
Portal
A Portal
is something that you want to render somewhere else.
It can be attach to / detached from a PortalOutlet
.
Properties
Name | Description |
---|---|
|
Whether this portal is attached to a host. |
Methods
attach | |
---|---|
Attach this portal to a host. |
|
Parameters | |
host PortalOutlet
|
|
Returns | |
T
|
|
detach | |
---|---|
Detach this portal from its host |
setAttachedHost | |
---|---|
Sets the PortalOutlet reference without performing |
|
Parameters | |
host PortalOutlet
|
|
ComponentPortal
extends
Portal
A ComponentPortal
is a portal that instantiates some Component upon attachment.
Properties
Name | Description |
---|---|
|
The type of the component that will be instantiated for attachment. |
|
Injector used for the instantiation of the component. |
|
Whether this portal is attached to a host. |
|
List of DOM nodes that should be projected through |
|
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. |
Deprecated
|
Methods
attach | |
---|---|
Attach this portal to a host. |
|
Parameters | |
host PortalOutlet
|
|
Returns | |
T
|
|
detach | |
---|---|
Detach this portal from its host |
setAttachedHost | |
---|---|
Sets the PortalOutlet reference without performing |
|
Parameters | |
host PortalOutlet
|
|
TemplatePortal
extends
Portal
A TemplatePortal
is a portal that represents some embedded template (TemplateRef).
Properties
Name | Description |
---|---|
|
Contextual data to be passed in to the embedded view. |
|
The injector to use for the embedded view. |
|
Whether this portal is attached to a host. |
|
|
|
The embedded template that will be used to instantiate an embedded View in the host. |
|
Reference to the ViewContainer into which the template will be stamped out. |
Methods
attach | |
---|---|
Attach the portal to the provided |
|
Parameters | |
host PortalOutlet
|
|
context C = this.context
|
|
Returns | |
EmbeddedViewRef<C>
|
|
detach |
---|
setAttachedHost | |
---|---|
Sets the PortalOutlet reference without performing |
|
Parameters | |
host PortalOutlet
|
|
DomPortal
extends
Portal
A DomPortal
is a portal whose DOM element will be taken from its current position
in the DOM and moved into a portal outlet, when it is attached. On detach, the content
will be restored to its original position.
Properties
Name | Description |
---|---|
|
DOM node hosting the portal's content. |
|
Whether this portal is attached to a host. |
Methods
attach | |
---|---|
Attach this portal to a host. |
|
Parameters | |
host PortalOutlet
|
|
Returns | |
T
|
|
detach | |
---|---|
Detach this portal from its host |
setAttachedHost | |
---|---|
Sets the PortalOutlet reference without performing |
|
Parameters | |
host PortalOutlet
|
|
BasePortalOutlet
Partial implementation of PortalOutlet that handles attaching ComponentPortal and TemplatePortal.
Properties
Name | Description |
---|---|
|
Methods
attach | |
---|---|
Parameters | |
portal ComponentPortal<T>
|
|
Returns | |
ComponentRef<T>
|
|
attach | |
---|---|
Parameters | |
portal TemplatePortal<T>
|
|
Returns | |
EmbeddedViewRef<T>
|
|
attach | |
---|---|
Parameters | |
portal any
|
|
Returns | |
any
|
|
attachComponentPortal | |
---|---|
Parameters | |
portal ComponentPortal<T>
|
|
Returns | |
ComponentRef<T>
|
|
attachTemplatePortal | |
---|---|
Parameters | |
portal TemplatePortal<C>
|
|
Returns | |
EmbeddedViewRef<C>
|
|
detach | |
---|---|
Detaches a previously attached portal. |
dispose | |
---|---|
Permanently dispose of this portal host. |
hasAttached | |
---|---|
Whether this host has an attached portal. |
|
Returns | |
boolean
|
|
BasePortalHost
extends
BasePortalOutlet
Properties
Name | Description |
---|---|
|
Methods
attach | |
---|---|
Parameters | |
portal ComponentPortal<T>
|
|
Returns | |
ComponentRef<T>
|
|
attach | |
---|---|
Parameters | |
portal TemplatePortal<T>
|
|
Returns | |
EmbeddedViewRef<T>
|
|
attach | |
---|---|
Parameters | |
portal any
|
|
Returns | |
any
|
|
attachComponentPortal | |
---|---|
Parameters | |
portal ComponentPortal<T>
|
|
Returns | |
ComponentRef<T>
|
|
attachTemplatePortal | |
---|---|
Parameters | |
portal TemplatePortal<C>
|
|
Returns | |
EmbeddedViewRef<C>
|
|
detach | |
---|---|
Detaches a previously attached portal. |
dispose | |
---|---|
Permanently dispose of this portal host. |
hasAttached | |
---|---|
Whether this host has an attached portal. |
|
Returns | |
boolean
|
|
DomPortalOutlet
extends
BasePortalOutlet
A PortalOutlet for attaching portals to an arbitrary DOM element outside of the Angular application context.
Properties
Name | Description |
---|---|
|
Element into which the content is projected. |
Deprecated
|
Attaches a DOM portal by transferring its content into the outlet. |
Methods
attach | |
---|---|
Parameters | |
portal ComponentPortal<T>
|
|
Returns | |
ComponentRef<T>
|
|
attach | |
---|---|
Parameters | |
portal TemplatePortal<T>
|
|
Returns | |
EmbeddedViewRef<T>
|
|
attach | |
---|---|
Parameters | |
portal any
|
|
Returns | |
any
|
|
attachComponentPortal | |
---|---|
Attach the given ComponentPortal to DOM element. |
|
Parameters | |
portal ComponentPortal<T>
|
Portal to be attached |
Returns | |
ComponentRef<T>
|
Reference to the created component. |
attachTemplatePortal | |
---|---|
Attaches a template portal to the DOM as an embedded view. |
|
Parameters | |
portal TemplatePortal<C>
|
Portal to be attached. |
Returns | |
EmbeddedViewRef<C>
|
Reference to the created embedded view. |
detach | |
---|---|
Detaches a previously attached portal. |
dispose | |
---|---|
Clears out a portal from the DOM. |
hasAttached | |
---|---|
Whether this host has an attached portal. |
|
Returns | |
boolean
|
|
DomPortalHost
extends
DomPortalOutlet
Properties
Name | Description |
---|---|
|
Element into which the content is projected. |
Deprecated
|
Attaches a DOM portal by transferring its content into the outlet. |
Methods
attach | |
---|---|
Parameters | |
portal ComponentPortal<T>
|
|
Returns | |
ComponentRef<T>
|
|
attach | |
---|---|
Parameters | |
portal TemplatePortal<T>
|
|
Returns | |
EmbeddedViewRef<T>
|
|
attach | |
---|---|
Parameters | |
portal any
|
|
Returns | |
any
|
|
attachComponentPortal | |
---|---|
Attach the given ComponentPortal to DOM element. |
|
Parameters | |
portal ComponentPortal<T>
|
Portal to be attached |
Returns | |
ComponentRef<T>
|
Reference to the created component. |
attachTemplatePortal | |
---|---|
Attaches a template portal to the DOM as an embedded view. |
|
Parameters | |
portal TemplatePortal<C>
|
Portal to be attached. |
Returns | |
EmbeddedViewRef<C>
|
Reference to the created embedded view. |
detach | |
---|---|
Detaches a previously attached portal. |
dispose | |
---|---|
Clears out a portal from the DOM. |
hasAttached | |
---|---|
Whether this host has an attached portal. |
|
Returns | |
boolean
|
|
Interfaces
ComponentType
Interface that can be used to generically type a class.
Methods
new | |
---|---|
Parameters | |
...args any[]
|
|
Returns | |
T
|
|
PortalOutlet
A PortalOutlet
is a space that can contain a single Portal
.
Methods
attach | |
---|---|
Attaches a portal to this outlet. |
|
Parameters | |
portal Portal<any>
|
|
Returns | |
any
|
|
detach | |
---|---|
Detaches the currently attached portal from this outlet. |
|
Returns | |
any
|
|
dispose | |
---|---|
Performs cleanup before the outlet is destroyed. |
hasAttached | |
---|---|
Whether there is currently a portal attached to this outlet. |
|
Returns | |
boolean
|
|
Type aliases
PortalHost
type PortalHost = PortalOutlet;
CdkPortalOutletAttachedRef
Possible attached references to the CdkPortalOutlet.
type CdkPortalOutletAttachedRef = ComponentRef<any> | EmbeddedViewRef<any> | null;