# 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

changed
compareWith?

### Accessors

selected

### Methods

clear
deselect
hasValue
isEmpty
isMultipleSelection
isSelected
select
setSelection
sort
toggle

##
Constructors

### constructor

- new SelectionModel<T>(
  _multiple?: boolean,
  initiallySelectedValues?: T[],
  _emitChanges?: boolean,
  compareWith?: (o1: T, o2: T) => boolean,
  ): SelectionModel<T>

  #### Type Parameters

  - T

  #### Parameters

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

  #### Returns SelectionModel<T>

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

##
Properties

### `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: T, o2: T) => 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

### clear

- clear(flushEvent?: boolean): 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: T[]): boolean | void

  Deselects a value or an array of values.

  #### Parameters

  - ...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: T): 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: T[]): boolean | void

  Selects a value or an array of values.

  #### Parameters

  - ...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: T[]): boolean | void

  Sets the selected values

  #### Parameters

  - ...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?: (a: T, b: T) => number): void

  Sorts the selected values based on a predicate function.

  #### Parameters

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

  #### Returns void

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

### toggle

- toggle(value: T): 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