import {PortalModule} from '@angular/cdk/portal';
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: [cdk-portal] [cdkPortal] [portal]
Exported as: cdkPortalName | Description |
---|---|
|
Contextual data to be passed in to 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. |
attach | |
---|---|
Attach the portal to the provided |
|
Parameters | |
host PortalOutlet
|
|
context C = this.context
|
|
Returns | |
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] [cdkPortalHost] [portalHost]
Exported as: cdkPortalOutlet, cdkPortalHostName | 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. |
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 using the ComponentFactoryResolver. |
|
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 PortlHost 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
|
|
Portal
A Portal
is something that you want to render somewhere else.
It can be attach to / detached from a PortalOutlet
.
Name | Description |
---|---|
|
Whether this portal is attached to a host. |
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.
Name | Description |
---|---|
|
The type of the component that will be instantiated for attachment. |
|
Alternate |
|
[Optional] Injector used for the instantiation of the component. |
|
Whether this portal is attached to a host. |
|
[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. |
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).
Name | Description |
---|---|
|
Contextual data to be passed in to 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. |
attach | |
---|---|
Attach the portal to the provided |
|
Parameters | |
host PortalOutlet
|
|
context C = this.context
|
|
Returns | |
C
|
|
detach |
---|
setAttachedHost | |
---|---|
Sets the PortalOutlet reference without performing |
|
Parameters | |
host PortalOutlet
|
|
BasePortalOutlet
Partial implementation of PortalOutlet that handles attaching ComponentPortal and TemplatePortal.
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.
Name | Description |
---|---|
|
Element into which the content is projected. |
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 using the ComponentFactoryResolver. |
|
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
|
|
ComponentType
Interface that can be used to generically type a class.
new | |
---|---|
Parameters | |
...args any[]
|
|
Returns | |
T
|
|
PortalOutlet
A PortalOutlet
is an space that can contain a single Portal
.
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
|
|
CdkPortalOutletAttachedRef
Possible attached references to the CdkPortalOutlet.
type CdkPortalOutletAttachedRef = ComponentRef<any> | EmbeddedViewRef<any> | null;