API for list

API reference for Angular Material list

import {MatListModule} from '@angular/material/list';

Selector: mat-list-option

Exported as: matListOption
Properties
Name Description
@Input()

color: ThemePalette

Theme color of the list option. This sets the color of the checkbox/radio. This API is supported in M2 themes only, it has no effect in M3 themes. For color customization in M3, see https://material.angular.io/components/list/styling.

For information on applying color variants in M3, see https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants

@Input()

disableRipple: boolean

Whether ripples for list items are disabled.

@Input()

disabled: boolean

Whether the list-item is disabled.

@Input()

lines: string | number

The number of lines this list item should reserve space for. If not specified, lines are inferred based on the projected content.

Explicitly specifying the number of lines is useful if you want to acquire additional space and enable the wrapping of text. The unscoped text content of a list item will always be able to take up the remaining space of the item, unless it represents the title.

A maximum of three lines is supported as per the Material Design specification.

@Input()

selected: boolean

Whether the option is selected.

@Input()

togglePosition: MatListOptionTogglePosition

Whether the label should appear before or after the checkbox/radio. Defaults to 'after'

@Input()

value: any

Value of the option

@Input()
Deprecated

checkboxPosition: MatListOptionTogglePosition

Whether the label should appear before or after the checkbox/radio. Defaults to 'after'

Methods
focus

Allows for programmatic focusing of the option.

getLabel

Gets the text label of the list option. Used for the typeahead functionality in the list.

toggle

Toggles the selection state of the option.

Selector: mat-action-list

Exported as: matActionList
Properties
Name Description
@Input()

disableRipple: boolean

Whether ripples for all list items is disabled.

@Input()

disabled: boolean

Whether the entire list is disabled. When disabled, the list itself and each of its list items are disabled.

Selector: mat-list

Exported as: matList
Properties
Name Description
@Input()

disableRipple: boolean

Whether ripples for all list items is disabled.

@Input()

disabled: boolean

Whether the entire list is disabled. When disabled, the list itself and each of its list items are disabled.

Selector: mat-list-item a[mat-list-item] button[mat-list-item]

Exported as: matListItem
Properties
Name Description
@Input()

activated: boolean

Indicates whether an item in a <mat-nav-list> is the currently active page.

@Input()

disableRipple: boolean

Whether ripples for list items are disabled.

@Input()

disabled: boolean

Whether the list-item is disabled.

@Input()

lines: string | number

The number of lines this list item should reserve space for. If not specified, lines are inferred based on the projected content.

Explicitly specifying the number of lines is useful if you want to acquire additional space and enable the wrapping of text. The unscoped text content of a list item will always be able to take up the remaining space of the item, unless it represents the title.

A maximum of three lines is supported as per the Material Design specification.

Selector: mat-nav-list

Exported as: matNavList
Properties
Name Description
@Input()

disableRipple: boolean

Whether ripples for all list items is disabled.

@Input()

disabled: boolean

Whether the entire list is disabled. When disabled, the list itself and each of its list items are disabled.

Selector: mat-selection-list

Exported as: matSelectionList
Properties
Name Description
@Input()

color: ThemePalette

Theme color of the selection list. This sets the checkbox color for all list options. This API is supported in M2 themes only, it has no effect in M3 themes. For color customization in M3, see https://material.angular.io/components/list/styling.

For information on applying color variants in M3, see https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants

@Input()

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

Function used for comparing an option against the selected value when determining which options should appear as selected. The first argument is the value of an options. The second one is a value from the selected value. A boolean must be returned.

@Input()

disableRipple: boolean

Whether ripples for all list items is disabled.

@Input()

disabled: boolean

Whether the entire selection list is disabled. When true, each list item is also disabled and each list item is removed from the tab order (has tabindex="-1").

@Input()

hideSingleSelectionIndicator: boolean

Whether radio indicator for all list items is hidden.

@Input()

multiple: boolean

Whether selection is limited to one or multiple items (default multiple).

@Output()

selectionChange: EventEmitter<MatSelectionListChange>

Emits a change event whenever the selected state of an option changes.

options: QueryList<MatListOption>

The option components contained within this selection-list.

selectedOptions: SelectionModel<MatListOption>

The currently selected options.

Methods
deselectAll

Deselects all of the options. Returns the options that changed as a result.

Returns
MatListOption[]

focus

Focuses the selection list.

Parameters

options?

FocusOptions

selectAll

Selects all of the options. Returns the options that changed as a result.

Returns
MatListOption[]

Directive capturing the title of a list item. A list item usually consists of a title and optional secondary or tertiary lines.

Text content for the title never wraps. There can only be a single title per list item.

Selector: [matListItemTitle]

Directive capturing a line in a list item. A list item usually consists of a title and optional secondary or tertiary lines.

Text content inside a line never wraps. There can be at maximum two lines per list item.

Selector: [matListItemLine]

Directive matching an optional meta section for list items.

List items can reserve space at the end of an item to display a control, button or additional text content.

Selector: [matListItemMeta]

Directive matching an optional avatar within a list item.

List items can reserve space at the beginning of an item to display an avatar.

Selector: [matListItemAvatar]

Directive matching an optional icon within a list item.

List items can reserve space at the beginning of an item to display an icon.

Selector: [matListItemIcon]

Change event that is being fired whenever the selected state of an option changes.

Properties
Name Description

options: MatListOption[]

Reference to the options that have been changed.

source: MatSelectionList

Reference to the selection list that emitted the event.

Object that can be used to configure the default options for the list module.

Properties
Name Description

hideSingleSelectionIndicator: boolean

Whether icon indicators should be hidden for single-selection.

Type describing possible positions of a checkbox or radio in a list option with respect to the list item's text.

type MatListOptionTogglePosition = 'before' | 'after';

Injection token that can be used to inject instances of MatList. It serves as alternative token to the actual MatList class which could cause unnecessary retention of the class and its component metadata.

const MAT_LIST: InjectionToken<MatList>;

Injection token that can be used to inject instances of MatNavList. It serves as alternative token to the actual MatNavList class which could cause unnecessary retention of the class and its component metadata.

const MAT_NAV_LIST: InjectionToken<MatNavList>;
const MAT_SELECTION_LIST_VALUE_ACCESSOR: any;

Injection token that can be used to provide the default options for the list module.

const MAT_LIST_CONFIG: InjectionToken<MatListConfig>;

API reference for Angular Material list-testing

import {MatSubheaderHarness} from '@angular/material/list/testing';

Harness for interacting with a list subheader.

Properties
Name Description

static hostSelector: '.mat-mdc-subheader'

Methods
async
getText

Gets the full text content of the list item (including text from any font icons).

Returns
Promise<string>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

static
with
Parameters

options

SubheaderHarnessFilters = {}

Returns
HarnessPredicate<MatSubheaderHarness>

Harness for interacting with a action-list in tests.

Properties
Name Description

static hostSelector: '.mat-mdc-action-list'

The selector for the host element of a MatActionList instance.

Methods
getItems

Gets a list of harnesses representing the items in this list.

Parameters

filters?

F

Optional filters used to narrow which harnesses are included

Returns
Promise<C[]>

The list of items matching the given filters.

getItemsGroupedByDividers

Gets a list of sub-lists representing the list items grouped by dividers. If the list has no dividers it is represented as a list with a single sub-list.

Parameters

filters?

F

Optional filters used to narrow which list item harnesses are included

Returns
Promise<C[][]>

The list of items matching the given filters, grouped into sub-lists by divider.

getItemsGroupedBySubheader

Gets a list of ListSection representing the list items grouped by subheaders. If the list has no subheaders it is represented as a single ListSection with an undefined heading property.

Parameters

filters?

F

Optional filters used to narrow which list item harnesses are included

Returns
Promise<ListSection<C>[]>

The list of items matching the given filters, grouped into sections by subheader.

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader: false; divider: false; }

Returns
Promise<[ ]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader: false; divider: false; }

Returns
Promise<C[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader?: false | SubheaderHarnessFilters; divider: false; }

Returns
Promise<MatSubheaderHarness[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader: false; divider?: false | DividerHarnessFilters; }

Returns
Promise<MatDividerHarness[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader?: false | SubheaderHarnessFilters; divider: false; }

Returns
Promise<(C | MatSubheaderHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader: false; divider?: false | DividerHarnessFilters; }

Returns
Promise<(C | MatDividerHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader?: false | SubheaderHarnessFilters; divider?: false | DividerHarnessFilters; }

Returns
Promise<(MatSubheaderHarness | MatDividerHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters?

{ item?: false | F; subheader?: false | SubheaderHarnessFilters; divider?: false | DividerHarnessFilters; }

Returns
Promise<(C | MatSubheaderHarness | MatDividerHarness)[]>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

static
with

Gets a HarnessPredicate that can be used to search for an action list with specific attributes.

Parameters

options

ActionListHarnessFilters = {}

Options for filtering which action list instances are considered a match.

Returns
HarnessPredicate<T>

a HarnessPredicate configured with the given options.

Harness for interacting with an action list item.

Properties
Name Description

static hostSelector: `${MatActionListHarness.hostSelector} .mat-mdc-list-item`

The selector for the host element of a MatListItem instance.

Methods
async
blur

Blurs the action list item.

Returns
Promise<void>

Promise that resolves when the action completes.

async
click

Clicks on the action list item.

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus

Focuses the action list item.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getAllChildLoaders
Parameters

selector

S

Returns
Promise<HarnessLoader[]>

async
getAllHarnesses
Parameters

query

HarnessQuery<T>

Returns
Promise<T[]>

async
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

getFullText

Gets the full text content of the list item, excluding text from icons and avatars.

Returns
Promise<string>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

getSecondaryText

Gets the secondary line text of the list item. Null if the list item does not have a secondary line.

Returns
Promise<string | null>

getTertiaryText

Gets the tertiary line text of the list item. Null if the list item does not have a tertiary line.

Returns
Promise<string | null>

getTitle

Gets the title of the list item.

Returns
Promise<string>

getType

Gets the type of the list item, currently describing how many lines there are.

Returns
Promise<MatListItemType>

hasAvatar

Whether this list item has an avatar.

Returns
Promise<boolean>

async
hasHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<boolean>

hasIcon

Whether this list item has an icon.

Returns
Promise<boolean>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

isDisabled

Whether the list item is disabled.

Returns
Promise<boolean>

async
isFocused

Whether the action list item is focused.

Returns
Promise<boolean>

static
with

Gets a HarnessPredicate that can be used to search for a list item with specific attributes.

Parameters

options

ActionListItemHarnessFilters = {}

Options for filtering which action list item instances are considered a match.

Returns
HarnessPredicate<T>

a HarnessPredicate configured with the given options.

Deprecated
getText

Gets the full text content of the list item, excluding text from icons and avatars.

Returns
Promise<string>

Harness for interacting with a list in tests.

Properties
Name Description

static hostSelector: '.mat-mdc-list'

The selector for the host element of a MatList instance.

Methods
getItems

Gets a list of harnesses representing the items in this list.

Parameters

filters?

F

Optional filters used to narrow which harnesses are included

Returns
Promise<C[]>

The list of items matching the given filters.

getItemsGroupedByDividers

Gets a list of sub-lists representing the list items grouped by dividers. If the list has no dividers it is represented as a list with a single sub-list.

Parameters

filters?

F

Optional filters used to narrow which list item harnesses are included

Returns
Promise<C[][]>

The list of items matching the given filters, grouped into sub-lists by divider.

getItemsGroupedBySubheader

Gets a list of ListSection representing the list items grouped by subheaders. If the list has no subheaders it is represented as a single ListSection with an undefined heading property.

Parameters

filters?

F

Optional filters used to narrow which list item harnesses are included

Returns
Promise<ListSection<C>[]>

The list of items matching the given filters, grouped into sections by subheader.

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader: false; divider: false; }

Returns
Promise<[ ]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader: false; divider: false; }

Returns
Promise<C[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader?: false | SubheaderHarnessFilters; divider: false; }

Returns
Promise<MatSubheaderHarness[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader: false; divider?: false | DividerHarnessFilters; }

Returns
Promise<MatDividerHarness[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader?: false | SubheaderHarnessFilters; divider: false; }

Returns
Promise<(C | MatSubheaderHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader: false; divider?: false | DividerHarnessFilters; }

Returns
Promise<(C | MatDividerHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader?: false | SubheaderHarnessFilters; divider?: false | DividerHarnessFilters; }

Returns
Promise<(MatSubheaderHarness | MatDividerHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters?

{ item?: false | F; subheader?: false | SubheaderHarnessFilters; divider?: false | DividerHarnessFilters; }

Returns
Promise<(C | MatSubheaderHarness | MatDividerHarness)[]>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

static
with

Gets a HarnessPredicate that can be used to search for a list with specific attributes.

Parameters

options

ListHarnessFilters = {}

Options for filtering which list instances are considered a match.

Returns
HarnessPredicate<T>

a HarnessPredicate configured with the given options.

Harness for interacting with a list item.

Properties
Name Description

static hostSelector: `${MatListHarness.hostSelector} .mat-mdc-list-item`

The selector for the host element of a MatListItem instance.

Methods
async
getAllChildLoaders
Parameters

selector

S

Returns
Promise<HarnessLoader[]>

async
getAllHarnesses
Parameters

query

HarnessQuery<T>

Returns
Promise<T[]>

async
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

getFullText

Gets the full text content of the list item, excluding text from icons and avatars.

Returns
Promise<string>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

getSecondaryText

Gets the secondary line text of the list item. Null if the list item does not have a secondary line.

Returns
Promise<string | null>

getTertiaryText

Gets the tertiary line text of the list item. Null if the list item does not have a tertiary line.

Returns
Promise<string | null>

getTitle

Gets the title of the list item.

Returns
Promise<string>

getType

Gets the type of the list item, currently describing how many lines there are.

Returns
Promise<MatListItemType>

hasAvatar

Whether this list item has an avatar.

Returns
Promise<boolean>

async
hasHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<boolean>

hasIcon

Whether this list item has an icon.

Returns
Promise<boolean>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

isDisabled

Whether the list item is disabled.

Returns
Promise<boolean>

static
with

Gets a HarnessPredicate that can be used to search for a list item with specific attributes.

Parameters

options

ListItemHarnessFilters = {}

Options for filtering which list item instances are considered a match.

Returns
HarnessPredicate<T>

a HarnessPredicate configured with the given options.

Deprecated
getText

Gets the full text content of the list item, excluding text from icons and avatars.

Returns
Promise<string>

Harness for interacting with a mat-nav-list in tests.

Properties
Name Description

static hostSelector: '.mat-mdc-nav-list'

The selector for the host element of a MatNavList instance.

Methods
getItems

Gets a list of harnesses representing the items in this list.

Parameters

filters?

F

Optional filters used to narrow which harnesses are included

Returns
Promise<C[]>

The list of items matching the given filters.

getItemsGroupedByDividers

Gets a list of sub-lists representing the list items grouped by dividers. If the list has no dividers it is represented as a list with a single sub-list.

Parameters

filters?

F

Optional filters used to narrow which list item harnesses are included

Returns
Promise<C[][]>

The list of items matching the given filters, grouped into sub-lists by divider.

getItemsGroupedBySubheader

Gets a list of ListSection representing the list items grouped by subheaders. If the list has no subheaders it is represented as a single ListSection with an undefined heading property.

Parameters

filters?

F

Optional filters used to narrow which list item harnesses are included

Returns
Promise<ListSection<C>[]>

The list of items matching the given filters, grouped into sections by subheader.

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader: false; divider: false; }

Returns
Promise<[ ]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader: false; divider: false; }

Returns
Promise<C[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader?: false | SubheaderHarnessFilters; divider: false; }

Returns
Promise<MatSubheaderHarness[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader: false; divider?: false | DividerHarnessFilters; }

Returns
Promise<MatDividerHarness[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader?: false | SubheaderHarnessFilters; divider: false; }

Returns
Promise<(C | MatSubheaderHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader: false; divider?: false | DividerHarnessFilters; }

Returns
Promise<(C | MatDividerHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader?: false | SubheaderHarnessFilters; divider?: false | DividerHarnessFilters; }

Returns
Promise<(MatSubheaderHarness | MatDividerHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters?

{ item?: false | F; subheader?: false | SubheaderHarnessFilters; divider?: false | DividerHarnessFilters; }

Returns
Promise<(C | MatSubheaderHarness | MatDividerHarness)[]>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

static
with

Gets a HarnessPredicate that can be used to search for a nav list with specific attributes.

Parameters

options

NavListHarnessFilters = {}

Options for filtering which nav list instances are considered a match.

Returns
HarnessPredicate<T>

a HarnessPredicate configured with the given options.

Harness for interacting with a nav-list item.

Properties
Name Description

static hostSelector: `${MatNavListHarness.hostSelector} .mat-mdc-list-item`

The selector for the host element of a MatListItem instance.

Methods
async
blur

Blurs the nav list item.

Returns
Promise<void>

Promise that resolves when the action completes.

async
click

Clicks on the nav list item.

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus

Focuses the nav list item.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getAllChildLoaders
Parameters

selector

S

Returns
Promise<HarnessLoader[]>

async
getAllHarnesses
Parameters

query

HarnessQuery<T>

Returns
Promise<T[]>

async
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

getFullText

Gets the full text content of the list item, excluding text from icons and avatars.

Returns
Promise<string>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

async
getHref

Gets the href for this nav list item.

Returns
Promise<string | null>

getSecondaryText

Gets the secondary line text of the list item. Null if the list item does not have a secondary line.

Returns
Promise<string | null>

getTertiaryText

Gets the tertiary line text of the list item. Null if the list item does not have a tertiary line.

Returns
Promise<string | null>

getTitle

Gets the title of the list item.

Returns
Promise<string>

getType

Gets the type of the list item, currently describing how many lines there are.

Returns
Promise<MatListItemType>

hasAvatar

Whether this list item has an avatar.

Returns
Promise<boolean>

async
hasHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<boolean>

hasIcon

Whether this list item has an icon.

Returns
Promise<boolean>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

async
isActivated

Whether the list item is activated. Should only be used for nav list items.

Returns
Promise<boolean>

isDisabled

Whether the list item is disabled.

Returns
Promise<boolean>

async
isFocused

Whether the nav list item is focused.

Returns
Promise<boolean>

static
with

Gets a HarnessPredicate that can be used to search for a nav list item with specific attributes.

Parameters

options

NavListItemHarnessFilters = {}

Options for filtering which nav list item instances are considered a match.

Returns
HarnessPredicate<T>

a HarnessPredicate configured with the given options.

Deprecated
getText

Gets the full text content of the list item, excluding text from icons and avatars.

Returns
Promise<string>

Harness for interacting with a selection-list in tests.

Properties
Name Description

static hostSelector: '.mat-mdc-selection-list'

The selector for the host element of a MatSelectionList instance.

Methods
async
deselectItems

Deselects all items matching any of the given filters.

Parameters

filters

Filters that specify which items should be deselected.

...filters

ListItemHarnessFilters[]

Returns
Promise<void>

Promise that resolves when the action completes.

getItems

Gets a list of harnesses representing the items in this list.

Parameters

filters?

F

Optional filters used to narrow which harnesses are included

Returns
Promise<C[]>

The list of items matching the given filters.

getItemsGroupedByDividers

Gets a list of sub-lists representing the list items grouped by dividers. If the list has no dividers it is represented as a list with a single sub-list.

Parameters

filters?

F

Optional filters used to narrow which list item harnesses are included

Returns
Promise<C[][]>

The list of items matching the given filters, grouped into sub-lists by divider.

getItemsGroupedBySubheader

Gets a list of ListSection representing the list items grouped by subheaders. If the list has no subheaders it is represented as a single ListSection with an undefined heading property.

Parameters

filters?

F

Optional filters used to narrow which list item harnesses are included

Returns
Promise<ListSection<C>[]>

The list of items matching the given filters, grouped into sections by subheader.

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader: false; divider: false; }

Returns
Promise<[ ]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader: false; divider: false; }

Returns
Promise<C[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader?: false | SubheaderHarnessFilters; divider: false; }

Returns
Promise<MatSubheaderHarness[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader: false; divider?: false | DividerHarnessFilters; }

Returns
Promise<MatDividerHarness[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader?: false | SubheaderHarnessFilters; divider: false; }

Returns
Promise<(C | MatSubheaderHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item?: false | F; subheader: false; divider?: false | DividerHarnessFilters; }

Returns
Promise<(C | MatDividerHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters

{ item: false; subheader?: false | SubheaderHarnessFilters; divider?: false | DividerHarnessFilters; }

Returns
Promise<(MatSubheaderHarness | MatDividerHarness)[]>

getItemsWithSubheadersAndDividers
Parameters

filters?

{ item?: false | F; subheader?: false | SubheaderHarnessFilters; divider?: false | DividerHarnessFilters; }

Returns
Promise<(C | MatSubheaderHarness | MatDividerHarness)[]>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

async
isDisabled

Whether the selection list is disabled.

Returns
Promise<boolean>

async
selectItems

Selects all items matching any of the given filters.

Parameters

filters

Filters that specify which items should be selected.

...filters

ListOptionHarnessFilters[]

Returns
Promise<void>

Promise that resolves when the action completes.

static
with

Gets a HarnessPredicate that can be used to search for a selection list with specific attributes.

Parameters

options

SelectionListHarnessFilters = {}

Options for filtering which selection list instances are considered a match.

Returns
HarnessPredicate<T>

a HarnessPredicate configured with the given options.

Harness for interacting with a list option.

Properties
Name Description

static hostSelector: '.mat-mdc-list-option'

The selector for the host element of a MatListOption instance.

Methods
async
blur

Blurs the list option.

Returns
Promise<void>

Promise that resolves when the action completes.

async
deselect

Puts the list option in an unchecked state by toggling it if it is currently checked, or doing nothing if it is already unchecked.

async
focus

Focuses the list option.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getAllChildLoaders
Parameters

selector

S

Returns
Promise<HarnessLoader[]>

async
getAllHarnesses
Parameters

query

HarnessQuery<T>

Returns
Promise<T[]>

async
getCheckboxPosition

Gets the position of the checkbox relative to the list option content.

Returns
Promise<MatListOptionTogglePosition>

async
getChildLoader
Parameters

selector

S

Returns
Promise<HarnessLoader>

getFullText

Gets the full text content of the list item, excluding text from icons and avatars.

Returns
Promise<string>

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

async
getHarnessOrNull
Parameters

query

HarnessQuery<T>

Returns
Promise<T | null>

async
getRadioPosition

Gets the position of the radio relative to the list option content.

Returns
Promise<MatListOptionTogglePosition>

getSecondaryText

Gets the secondary line text of the list item. Null if the list item does not have a secondary line.

Returns
Promise<string | null>

getTertiaryText

Gets the tertiary line text of the list item. Null if the list item does not have a tertiary line.

Returns
Promise<string | null>

getTitle

Gets the title of the list item.

Returns
Promise<string>

getType

Gets the type of the list item, currently describing how many lines there are.

Returns
Promise<MatListItemType>

hasAvatar

Whether this list item has an avatar.

Returns
Promise<boolean>

async
hasHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<boolean>

hasIcon

Whether this list item has an icon.

Returns
Promise<boolean>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

isDisabled

Whether the list item is disabled.

Returns
Promise<boolean>

async
isFocused

Whether the list option is focused.

Returns
Promise<boolean>

async
isSelected

Whether the list option is selected.

Returns
Promise<boolean>

async
select

Puts the list option in a checked state by toggling it if it is currently unchecked, or doing nothing if it is already checked.

async
toggle

Toggles the checked state of the checkbox.

static
with

Gets a HarnessPredicate that can be used to search for a list option with specific attributes.

Parameters

options

ListOptionHarnessFilters = {}

Options for filtering which list option instances are considered a match.

Returns
HarnessPredicate<T>

a HarnessPredicate configured with the given options.

Deprecated
getText

Gets the full text content of the list item, excluding text from icons and avatars.

Returns
Promise<string>

Properties
Name Description

fullText: string | RegExp

secondaryText: string | RegExp | null

tertiaryText: string | RegExp | null

title: string | RegExp

Deprecated

text: string | RegExp

Properties
Name Description

activated: boolean

href: string | RegExp | null

Properties
Name Description

selected: boolean

Properties
Name Description

text: string | RegExp