CngxClickOutside
projects/common/interactive/keyboard/click-outside.directive.ts
Import#
import { CngxClickOutside } from '@cngx/common/interactive'
Description#
Emits when the user interacts outside the host element.
Listens for a configurable DOM event on the document and checks whether the event target is outside the host element's subtree. Useful for closing dropdowns, popovers, modals, and any overlay that should dismiss on outside interaction.
The event type defaults to 'pointerdown' which covers mouse, touch, and
pen input. Change it via the [eventType] input.
Dropdown dismiss
<div cngxClickOutside (clickOutside)="closeDropdown()" [enabled]="isOpen()">
<ul>…menu items…</ul>
</div>With custom event type
<div cngxClickOutside [eventType]="'click'" (clickOutside)="dismiss()">…</div>Metadata#
Relationships
Used by10
Index#
Outputs
Inputs#
"pointerdown" | "click" | "mousedown" | "touchstart"The DOM event type to listen for. 'pointerdown' covers both mouse and touch.
'pointerdown'Outputs#
PointerEvent | MouseEvent | TouchEventEmitted when the user interacts outside the host element.