CngxSortHeader
projects/common/data/sort/sort-header.directive.ts
Import#
import { CngxSortHeader } from '@cngx/common/data'
Description#
Molecule directive for sort-header elements.
Apply to any clickable header element. Consumer provides an explicit
[cngxSortRef] binding - no ancestor injection, no hidden wiring.
In multi-sort mode, Shift+click adds this column to the sort stack.
The priority() signal returns the 1-based position in the stack
(0 when not active), useful for showing sort-order badges.
<div cngxSort [multiSort]="true" #sort="cngxSort">
<button cngxSortHeader="name" [cngxSortRef]="sort" #h="cngxSortHeader">
Name
@if (h.isActive()) {
{{ h.isAsc() ? '↑' : '↓' }}
@if (sort.multiSort()) { <span>{{ h.priority() }}</span> }
}
</button>
</div>Metadata#
Host#
Index#
Methods
Inputs
Derived State
HostBindings
HostListeners
Inputs#
Instance Properties#
unknowntrue when this column is part of the active sort (primary or secondary).
this.state.isActiveunknown1-based position of this column in the sort stack.
Returns 0 when the column is not part of the active sort.
Only meaningful when multiSort is enabled on the owning CngxSort.
this.state.priorityMethods#
HostBindings#
| Binding | Expression |
|---|---|
[attr.aria-sort] | ariaSort() |
[class.cngx-sort-header--active] | isActive() |
[class.cngx-sort-header--asc] | isAsc() |
[class.cngx-sort-header--desc] | isDesc() |
HostListeners#
| Event | Handler |
|---|---|
(click) | click() |