CngxDialogClose
projects/common/dialog/dialog/dialog-close.directive.ts
Import#
import { CngxDialogClose } from '@cngx/common/dialog'
Description#
Close trigger for a dialog. Place on any clickable element inside a dialog.
- With a value:
[cngxDialogClose]="'confirm'"callsdialogRef.close(value) - Without a value:
cngxDialogClosecallsdialogRef.dismiss()
Automatically sets type="button" on <button> hosts to prevent
accidental form submission. Sets a default aria-label="Close dialog"
when the host has no descriptive text content (icon-only buttons).
<dialog cngxDialog>
<button [cngxDialogClose]="false">Cancel</button>
<button [cngxDialogClose]="true">Confirm</button>
</dialog>Metadata#
Host#
Index#
Properties
Methods
Derived State
HostBindings
HostListeners
Inputs#
string | undefinedExplicit aria-label override.
When not set, the directive auto-detects whether the host element
has descriptive text content. If it does (e.g. "Cancel", "Confirm"),
no aria-label is added. If the content is a single character,
empty, or visually an icon, aria-label defaults to "Close dialog".
undefined, { alias: 'cngxDialogCloseLabel' }unknownValue to pass to close(). When undefined, calls dismiss() instead.
undefined, { alias: 'cngxDialogClose' }Instance Properties#
unknownSet type="button" on
(this.elRef.nativeElement as HTMLElement).tagName === 'BUTTON' ? 'button' : nullMethods#
HostBindings#
| Binding | Expression |
|---|---|
[attr.type] | hostType |
[attr.aria-label] | ariaLabel() |
HostListeners#
| Event | Handler |
|---|---|
(click) | click() |