# Class SelectionModel<T>

Class to be used to power selecting one or more options from a list.

#### Type Parameters

- T

- Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:16

#####
Index

### Constructors

constructor

### Properties

_deselectedToEmit
_emitChanges
_multiple
_selected
_selectedToEmit
_selection
changed
compareWith?

### Accessors

selected

### Methods

_emitChangeEvent
_hasQueuedChanges
_markSelected
_unmarkAll
_unmarkSelected
_verifyValueAssignment
clear
deselect
hasValue
isEmpty
isMultipleSelection
isSelected
select
setSelection
sort
toggle

## Constructors

### constructor

- new SelectionModel<T>(_multiple?, initiallySelectedValues?, _emitChanges?, compareWith?): SelectionModel<T>

- #### Type Parameters

  - T

  #### Parameters

  - _multiple: boolean = false
  - `Optional` initiallySelectedValues: T[]
  - _emitChanges: boolean = true
  - `Optional` compareWith: ((o1, o2) => boolean)
    - - (o1, o2): boolean

      - #### Parameters

        - o1: T
        - o2: T

        #### Returns boolean

  #### Returns SelectionModel<T>

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:41

## Properties

### `Private` _deselectedToEmit

_deselectedToEmit: T[] = []

Keeps track of the deselected options that haven't been emitted by the change event.

- Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:21

### `Private` _emitChanges

_emitChanges: boolean = true

- Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:44

### `Private` _multiple

_multiple: boolean = false

- Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:42

### `Private` _selected

_selected: T[] = null

Cache for the array value of the selected items.

- Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:27

### `Private` _selectedToEmit

_selectedToEmit: T[] = []

Keeps track of the selected options that haven't been emitted by the change event.

- Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:24

### `Private` _selection

_selection: Set<T> = ...

Currently-selected values.

- Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:18

### `Readonly` changed

changed: Subject<SelectionChange<T>> = ...

Event emitted when the value has changed.

- Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:39

### `Optional` compareWith

compareWith?: ((o1, o2) => boolean)

#### Type declaration

- - (o1, o2): boolean

  - #### Parameters

    - o1: T
    - o2: T

    #### Returns boolean

- Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:45

## Accessors

### selected

- get selected(): T[]

- Selected values.

  #### Returns T[]

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:30

## Methods

### `Private` _emitChangeEvent

- _emitChangeEvent(): void

- Emits a change event and clears the records of selected and deselected values.

  #### Returns void

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:178

### `Private` _hasQueuedChanges

- _hasQueuedChanges(): boolean

- Whether there are queued up change to be emitted.

  #### Returns boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:240

### `Private` _markSelected

- _markSelected(value): void

- Selects a value.

  #### Parameters

  - value: T

  #### Returns void

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:195

### `Private` _unmarkAll

- _unmarkAll(): void

- Clears out the selected values.

  #### Returns void

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:223

### `Private` _unmarkSelected

- _unmarkSelected(value): void

- Deselects a value.

  #### Parameters

  - value: T

  #### Returns void

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:212

### `Private` _verifyValueAssignment

- _verifyValueAssignment(values): void

- Verifies the value assignment and throws an error if the specified value array is including multiple values while the selection model is not supporting multiple values.

  #### Parameters

  - values: T[]

  #### Returns void

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:233

### clear

- clear(flushEvent?): boolean | void

- 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 @breaking-change 16.0.0 make return type boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:123

### deselect

- deselect(...values): boolean | void

- Deselects a value or an array of values.

  #### Parameters

  - `Rest` ...values: T[]

    The values to deselect

  #### Returns boolean | void

  Whether the selection changed as a result of this call @breaking-change 16.0.0 make return type boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:79

### hasValue

- hasValue(): boolean

- Determines whether the model has a value.

  #### Returns boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:157

### isEmpty

- isEmpty(): boolean

- Determines whether the model does not have a value.

  #### Returns boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:150

### isMultipleSelection

- isMultipleSelection(): boolean

- Gets whether multiple values can be selected.

  #### Returns boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:173

### isSelected

- isSelected(value): boolean

- Determines whether a value is selected.

  #### Parameters

  - value: T

  #### Returns boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:135

### select

- select(...values): boolean | void

- Selects a value or an array of values.

  #### Parameters

  - `Rest` ...values: T[]

    The values to select

  #### Returns boolean | void

  Whether the selection changed as a result of this call @breaking-change 16.0.0 make return type boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:65

### setSelection

- setSelection(...values): boolean | void

- Sets the selected values

  #### Parameters

  - `Rest` ...values: T[]

    The new selected values

  #### Returns boolean | void

  Whether the selection changed as a result of this call @breaking-change 16.0.0 make return type boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:93

### sort

- sort(predicate?): void

- Sorts the selected values based on a predicate function.

  #### Parameters

  - `Optional` predicate: ((a, b) => number)
    - - (a, b): number

      - #### Parameters

        - a: T
        - b: T

        #### Returns number

  #### Returns void

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:164

### toggle

- toggle(value): boolean | void

- 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 @breaking-change 16.0.0 make return type boolean

  - Defined in packages/angular/material/table-system/src/lib/select-row/selection-model.ts:112