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. |
Deprecated
|
ARIA label for the sorting button. |
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()
|
Overrides the disable clear value of the containing MatSort for this MatSortable. |
@Input()
|
Whether the component 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()
|
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('matSortDisableClear')
|
Whether to disable the user from clearing the sort by finishing the sort direction cycle. May be overriden by the MatSortable's disable clear input. |
@Input( matSortDisabled)
|
Whether the component is disabled. |
@Input('matSortStart')
|
The direction to set when an MatSortable is initially sorted. May be overriden by the MatSortable's sort start. |
@Output('matSortChange')
|
Event emitted when the user changes either the active sort or sort direction. |
|
Stream that emits once during the directive/component's ngOnInit. |
|
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. |
Type aliases
SortDirection
type SortDirection = 'asc' | 'desc' | '';
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.
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>
|
|
MatSortHeaderHarness
extends
ComponentHarness
Harness for interacting with a standard Angular Material sort header in tests.
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>
|
|
Deprecated
async
getAriaLabel
|
|
---|---|
Gets the aria-label of the sort header. |
|
Returns | |
Promise<string | null>
|
|
Interfaces
SortHarnessFilters
SortHeaderHarnessFilters
Properties
Name | Description |
---|---|
|
|
|