Portal
Open a component or template above the whole page from code, inside a native <overlay>. import { LynxPortal, PortalRef, type PortalConfig } from '@blotch/angular-lynx';
For an overlay you can write in a template, use <overlay> directly.
Usage
API
LynxPortal
Creates native overlays and renders Angular content into them. Each call adds a new <overlay> as a direct child of the page, so it draws above all other content.
LynxPortal.open()
Creates the component inside a new overlay and returns its handle.
- The component takes part in change detection, and gets dependency injection and lifecycle hooks as usual.
config.inputssets its inputs once, after creation.- From an event handler, call it inside
setTimeout. See thesetTimeoutrule.
LynxPortal.openTemplate()
Renders a TemplateRef, such as one from viewChild(), inside a new overlay.
config.contextbecomes the template's context. It defaults to{}.config.inputsis ignored.- The same
setTimeoutrule applies.
PortalRef
The handle that open() and openTemplate() return. Keep it to update or close the overlay. Don't construct it yourself.
PortalRef.instance
The component instance. null for template portals.
PortalRef.setInput()
Sets one input on the component. Does nothing for template portals.
PortalRef.destroy()
Destroys the component or template view, detaches it from change detection, and removes the overlay. From an event handler, call it inside setTimeout.
Types
PortalConfig
Related
- Dialogs and overlays: when to use a portal,
<overlay>or a UI component. <overlay>- Threads
