CngxDialogRef
projects/common/dialog/dialog/dialog.service.ts
Import#
import { CngxDialogRef } from '@cngx/common/dialog'
Description#
Reference to a programmatically opened dialog.
Returned by CngxDialogOpener.open(). Provides both Signal-based access
(state, result) and Observable convenience methods (afterClosed(),
afterOpened()) for migration compatibility with MatDialogRef.
Signal-based result reading
const ref = dialog.open<boolean>(ConfirmDialog);
// In a computed or effect:
const wasCancelled = ref.result() === 'dismissed';Observable-based result reading
ref.afterClosed().subscribe(result => {
if (result !== 'dismissed') console.log('Confirmed:', result);
});Index#
Accessors
Methods#
ObservableObservable that emits the result when the dialog closes.
Emits exactly once with T | 'dismissed', then completes.
Compatible with MatDialogRef.afterClosed() usage patterns.
ObservableObservable that emits when the dialog finishes opening.
Emits exactly once with void when the state transitions to 'open',
then completes. Useful for post-open logic (e.g., focusing a specific
element after animation completes).
close(value: T)Close the dialog with a typed result value.
T- The result to deliver to consumers.
Accessors#
Current lifecycle state of the dialog.
Possible values: 'closed', 'opening', 'open', 'closing'.
The typed result signal.
undefinedbefore the dialog closes (reset on each open cycle)'dismissed'when dismissed via Escape or backdrop clickTwhen closed with an explicit value
ComponentRef | nullReference to the content component instance.
Returns null when the dialog was opened with a TemplateRef instead
of a component type.