API reference for Angular Material sort
import {MatSortModule} from '@angular/material/sort';
Services
MatSortHeaderIntl
To modify the labels and text displayed, create a new instance of MatSortHeaderIntl and include it in a custom provider.
Properties
Name | Description |
---|---|
|
Stream that emits whenever the labels here are changed. Use this to notify components if the labels have changed after initialization. |
Directives
MatSortHeader
Applies sorting behavior (click to change sort) and styles to an element, including an arrow to display the current sort direction.
Must be provided with an id and contained within a parent MatSort directive.
If used on header cells in a CdkTable, it will automatically default its id from its containing column definition.
Selector: [mat-sort-header]
Exported as: matSortHeaderProperties
Name | Description |
---|---|
@Input()
|
Sets the position of the arrow that displays when sorted. |
@Input({ transform: booleanAttribute })
|
Overrides the disable clear value of the containing MatSort for this MatSortable. |
@Input({ transform: booleanAttribute })
|
whether the sort header is disabled. |
@Input('mat-sort-header')
|
ID of this sort header. If used within the context of a CdkColumnDef, this will default to the column's name. |
@Input()
|
Description applied to MatSortHeader's button element with aria-describedby. This text should describe the action that will occur when the user clicks the sort header. |
@Input()
|
Overrides the sort start value of the containing MatSort for this MatSortable. |
MatSort
Container for MatSortables to manage the sort state and provide default sort parameters.
Selector: [matSort]
Exported as: matSortProperties
Name | Description |
---|---|
@Input('matSortActive')
|
The id of the most recently sorted MatSortable. |
@Input('matSortDirection')
|
The sort direction of the currently active MatSortable. |
@Input({ alias: 'matSortDisableClear', transform: booleanAttribute })
|
Whether to disable the user from clearing the sort by finishing the sort direction cycle. May be overridden by the MatSortable's disable clear input. |
@Input({ alias: 'matSortDisabled', transform: booleanAttribute })
|
Whether the sortable is disabled. |
@Input('matSortStart')
|
The direction to set when an MatSortable is initially sorted. May be overridden by the MatSortable's sort start. |
@Output('matSortChange')
|
Event emitted when the user changes either the active sort or sort direction. |
|
Emits when the paginator is initialized. |
|
Collection of all registered sortables that this directive manages. |
Methods
deregister | |
---|---|
Unregister function to be used by the contained MatSortables. Removes the MatSortable from the collection of contained MatSortables. |
|
Parameters | |
sortable MatSortable
|
|
getNextSortDirection | |
---|---|
Returns the next sort direction of the active sortable, checking for potential overrides. |
|
Parameters | |
sortable MatSortable
|
|
Returns | |
SortDirection
|
|
register | |
---|---|
Register function to be used by the contained MatSortables. Adds the MatSortable to the collection of MatSortables. |
|
Parameters | |
sortable MatSortable
|
|
sort | |
---|---|
Sets the active sort id and determines the new sort direction. |
|
Parameters | |
sortable MatSortable
|
|
Interfaces
MatSortable
Interface for a directive that holds sorting state consumed by MatSortHeader
.
Properties
Name | Description |
---|---|
|
Whether to disable clearing the sorting state. |
|
The id of the column being sorted. |
|
Starting sort direction. |
Sort
The current sort state.
Properties
Name | Description |
---|---|
|
The id of the column being sorted. |
|
The sort direction. |
MatSortDefaultOptions
Default options for mat-sort
.
Properties
Name | Description |
---|---|
|
Position of the arrow that displays when sorted. |
|
Whether to disable clearing the sorting state. |
Type aliases
SortDirection
type SortDirection = 'asc' | 'desc' | '';
SortHeaderArrowPosition
Position of the arrow that displays when sorted.
type SortHeaderArrowPosition = 'before' | 'after';
Constants
MAT_SORT_DEFAULT_OPTIONS
Injection token to be used to override the default options for mat-sort
.
const MAT_SORT_DEFAULT_OPTIONS: InjectionToken<MatSortDefaultOptions>;
API reference for Angular Material sort-testing
import {MatSortHarness} from '@angular/material/sort/testing';
Classes
MatSortHarness
extends
ComponentHarness
Harness for interacting with a standard mat-sort
in tests.
Properties
Name | Description |
---|---|
|
Methods
async
getActiveHeader
|
|
---|---|
Gets the selected header in the |
|
Returns | |
Promise<MatSortHeaderHarness | null>
|
|
async
getSortHeaders
|
|
---|---|
Gets all of the sort headers in the |
|
Parameters | |
filter SortHeaderHarnessFilters = {}
|
|
Returns | |
Promise<MatSortHeaderHarness[]>
|
|
async
host
|
|
---|---|
Gets a |
|
Returns | |
Promise<TestElement>
|
|
static
with
|
|
---|---|
Gets a |
|
Parameters | |
options SortHarnessFilters = {}
|
Options for narrowing the search. |
Returns | |
HarnessPredicate<MatSortHarness>
|
a |
MatSortHeaderHarness
extends
ComponentHarness
Harness for interacting with a standard Angular Material sort header in tests.
Properties
Name | Description |
---|---|
|
Methods
async
click
|
|
---|---|
Clicks the header to change its sorting direction. Only works if the header is enabled. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
getLabel
|
|
---|---|
Gets the label of the sort header. |
|
Returns | |
Promise<string>
|
|
async
getSortDirection
|
|
---|---|
Gets the sorting direction of the header. |
|
Returns | |
Promise<SortDirection>
|
|
async
host
|
|
---|---|
Gets a |
|
Returns | |
Promise<TestElement>
|
|
async
isActive
|
|
---|---|
Gets whether the sort header is currently being sorted by. |
|
Returns | |
Promise<boolean>
|
|
async
isDisabled
|
|
---|---|
Whether the sort header is disabled. |
|
Returns | |
Promise<boolean>
|
|
static
with
|
|
---|---|
Gets a |
|
Parameters | |
options SortHeaderHarnessFilters = {}
|
|
Returns | |
HarnessPredicate<MatSortHeaderHarness>
|
|
Interfaces
SortHarnessFilters
SortHeaderHarnessFilters
Properties
Name | Description |
---|---|
|
|
|