API reference for Angular CDK collections
Import symbols from @angular/cdk/collections
Services
UniqueSelectionDispatcher
Class to coordinate unique selection based on name. Intended to be consumed as an Angular service. This service is needed because native radio change events are only fired on the item currently being selected, and we still need to uncheck the previous selection.
This service does not store any IDs and names because they may change at any time, so it is less error-prone if they are simply passed through when the events occur.
Methods
listen | |
---|---|
Listen for future changes to item selection. |
|
Parameters | |
listener UniqueSelectionDispatcherListener
|
|
Returns | |
() => void
|
Function used to deregister listener |
notify | |
---|---|
Notify other items that selection for the given name has been set. |
|
Parameters | |
id string
|
ID of the item. |
name string
|
Name of the item. |
Classes
ArrayDataSource
extends
DataSource
DataSource wrapper for a native array.
Methods
connect | |
---|---|
Returns | |
Observable<readonly T[]>
|
|
disconnect |
---|
DataSource
Methods
connect | |
---|---|
Connects a collection viewer (such as a data-table) to this data source. Note that the stream provided will be accessed during change detection and should not directly change values that are bound in template views. |
|
Parameters | |
collectionViewer CollectionViewer
|
The component that exposes a view over the data provided by this data source. |
Returns | |
Observable<readonly T[]>
|
Observable that emits a new value when the data changes. |
disconnect | |
---|---|
Disconnects a collection viewer (such as a data-table) from this data source. Can be used to perform any clean-up or tear-down operations when a view is being destroyed. |
|
Parameters | |
collectionViewer CollectionViewer
|
The component that exposes a view over the data provided by this data source. |
SelectionModel
Class to be used to power selecting one or more options from a list.
Properties
Name | Description |
---|---|
|
Event emitted when the value has changed. |
|
|
|
Selected values. |
Methods
clear | |
---|---|
Clears all of the selected values. |
|
Parameters | |
flushEvent boolean = true
|
Whether to flush the changes in an event. If false, the changes to the selection will be flushed along with the next event. |
Returns | |
boolean | void
|
Whether the selection changed as a result of this call |
deselect | |
---|---|
Deselects a value or an array of values. |
|
Parameters | |
values
|
The values to deselect |
...values T[]
|
|
Returns | |
boolean | void
|
Whether the selection changed as a result of this call |
hasValue | |
---|---|
Determines whether the model has a value. |
|
Returns | |
boolean
|
|
isEmpty | |
---|---|
Determines whether the model does not have a value. |
|
Returns | |
boolean
|
|
isMultipleSelection | |
---|---|
Gets whether multiple values can be selected. |
isSelected | |
---|---|
Determines whether a value is selected. |
|
Parameters | |
value T
|
|
Returns | |
boolean
|
|
select | |
---|---|
Selects a value or an array of values. |
|
Parameters | |
values
|
The values to select |
...values T[]
|
|
Returns | |
boolean | void
|
Whether the selection changed as a result of this call |
setSelection | |
---|---|
Sets the selected values |
|
Parameters | |
values
|
The new selected values |
...values T[]
|
|
Returns | |
boolean | void
|
Whether the selection changed as a result of this call |
sort | |
---|---|
Sorts the selected values based on a predicate function. |
|
Parameters | |
predicate? (a: T, b: T) => number
|
|
toggle | |
---|---|
Toggles a value between selected and deselected. |
|
Parameters | |
value T
|
The value to toggle |
Returns | |
boolean | void
|
Whether the selection changed as a result of this call |
Interfaces
CollectionViewer
Interface for any component that provides a view of some data collection and wants to provide information regarding the view and any changes made.
Properties
Name | Description |
---|---|
|
A stream that emits whenever the |
TreeDataNodeFlattener
Interface for a class that can flatten hierarchical structured data and re-expand the flattened data back into its original structure. Should be used in conjunction with the cdk-tree.
Methods
expandFlattenedNodes | |
---|---|
Expands a flattened array of data into its hierarchical form using the provided expansion model. |
|
Parameters | |
nodes T[]
|
|
expansionModel SelectionModel<T>
|
|
Returns | |
T[]
|
|
flattenNodes | |
---|---|
Transforms a set of hierarchical structured data into a flattened data array. |
|
Parameters | |
structuredData any[]
|
|
Returns | |
T[]
|
|
nodeDescendents | |
---|---|
Put node descendants of node in array.
If |
|
Parameters | |
node T
|
|
nodes T[]
|
|
onlyExpandable boolean
|
|
Functions
isDataSource | |
---|---|
Checks whether an object is a data source. |
|
Parameters | |
value any
|
|
Returns | |
value is DataSource<any>
|
|
Type aliases
UniqueSelectionDispatcherListener
type UniqueSelectionDispatcherListener = (id: string, name: string) => void;
ListRange
Represents a range of numbers with a specified start and end.
type ListRange = {
start: number;
end: number;
};