表格 Table

table 的 API

Angular Material table API 参考文档

import {MatTableModule} from '@angular/material/table';

mat-table 的单元格定义。存放列的数据行单元格的模板以及单元格专有属性。

Cell definition for the mat-table. Captures the template of a column's data row cell as well as cell-specific properties.

选择器: [matCellDef]

mat-table 的表头单元格定义。存放列表头单元格的模板以及单元格专有属性。

Header cell definition for the mat-table. Captures the template of a column's header cell and as well as cell-specific properties.

选择器: [matHeaderCellDef]

mat-table 的表尾单元格定义。存放列的表尾单元格的模板以及单元格专有属性。

Footer cell definition for the mat-table. Captures the template of a column's footer cell and as well as cell-specific properties.

选择器: [matFooterCellDef]

mat-table 的列定义。定义一组可用于表列的单元格。

Column definition for the mat-table. Defines a set of cells available for a table column.

选择器: [matColumnDef]
属性
名称 描述
@Input('matColumnDef')

name: string

这个列的唯一名称。

Unique name for this column.

@Input()

sticky: boolean

是否应该使用粘性定位。

Whether sticky positioning should be applied.

@Input('stickyEnd')

stickyEnd: boolean

此列是否应粘性在该行的末尾。应该确保它模仿了混入接口 CanStick,当该值更改后必须把 _hasStickyChanged 设为 true。

Whether this column should be sticky positioned on the end of the row. Should make sure that it mimics the CanStick mixin such that _hasStickyChanged is set to true if the value has been changed.

cssClassFriendlyName: string

列名的转换后版本,可以作为 CSS 类名的一部分。只允许字母、数字和两个特殊字符 “-” 和 “_”。除此之外的字符都会替换为 “-”。

Transformed version of the column name that can be used as part of a CSS classname. Excludes all non-alphanumeric characters and the special characters '-' and '_'. Any characters that do not match are replaced by the '-' character.

方法
hasStickyChanged

此粘性组件的值是否自上次调用后发生了变化。

Whether the sticky value has changed since this was last called.

返回值

Returns

boolean
resetStickyChanged

对于粘性状态已被使用且未经检查的情况,重置脏检查。

Resets the dirty check for cases where the sticky state has been used without checking.

用于添加正确的类和角色的表头单元格模板容器。

Header cell template container that adds the right classes and role.

选择器: mat-header-cell th[mat-header-cell]

用于添加正确的类和角色的表尾单元格模板容器。

Footer cell template container that adds the right classes and role.

选择器: mat-footer-cell td[mat-footer-cell]

用于添加正确的类和角色的单元格模板容器。

Cell template container that adds the right classes and role.

选择器: mat-cell td[mat-cell]

采用 Material Design 样式的 CdkTable 封装器。

Wrapper for the CdkTable with Material design styles.

选择器: mat-table table[mat-table]
导出为: matTable
属性
名称 描述
@Input()

dataSource: CdkTableDataSourceInput<T>

该表格的数据源可以通过三种方式提供(按复杂程度排序):

The table's source of data, which can be provided in three ways (in order of complexity):

  • 简单数据数组(每个对象代表格一个表格行)

    Simple data array (each object represents one table row)

  • 每当数组发生变化时都会发出数据数组的流

    Stream that emits a data array each time the array changes

  • 那些实现了 connect / disconnect 接口的 DataSource

    DataSource object that implements the connect/disconnect interface.

如果提供了数组,那么在添加、删除或移动该数组的对象时,都必须通知该表格。 这可以通过调用 renderRows() 函数来完成,它会渲染自上次渲染表格以来的差异部分。如果数据数组的引用发生了变化,该表格会自动触发对行的更新。

If a data array is provided, the table must be notified when the array's objects are added, removed, or moved. This can be done by calling the renderRows() function which will render the diff since the last table render. If the data array reference is changed, the table will automatically trigger an update to the rows.

当提供一个可观察的流时,如果该流发出一个新的数据数组,该表格就会自动触发一次更新。

When providing an Observable stream, the table will trigger an update automatically when the stream emits a new array of data.

最后,在提供 DataSource 对象时,该表格将使用 connect 函数提供的 Observable 流,并在该流发出新的数据数组值时触发更新。 在表格的 ngOnDestroy 中,或者从表格中删除了数据源时,该表格会调用数据源的 disconnect 函数(这可能对清理在连接过程中注册的所有订阅很有帮助)。

Finally, when providing a DataSource object, the table will use the Observable stream provided by the connect function and trigger updates when that stream emits new data array values. During the table's ngOnDestroy or when the data source is removed from the table, the table will call the DataSource's disconnect function (may be useful for cleaning up any subscriptions registered during the connect process).

@Input()

fixedLayout: boolean

是否使用固定(fixed)表格布局。启用此选项会强制让所有列宽一致,并优化渲染原生表格的粘性样式。 对弹性(flex)表格无效。

Whether to use a fixed table layout. Enabling this option will enforce consistent column widths and optimize rendering sticky styles for native tables. No-op for flex tables.

@Input()

multiTemplateDataRows: boolean

通过计算哪些行的 'when' 谓词结果为 true 来允许其数据对象对应于多行。 如果 multiTemplateDataRows 为 false(这是默认值),那么每个数据对象都会渲染到其谓词结果为 true 的第一行(按照表格中定义的顺序), 否则就使用默认行(即没有 when 谓词的行)。

Whether to allow multiple rows per data object by evaluating which rows evaluate their 'when' predicate to true. If multiTemplateDataRows is false, which is the default value, then each dataobject will render the first row that evaluates its when predicate to true, in the order defined in the table, or otherwise the default row which does not have a when predicate.

@Input()

trackBy: TrackByFunction<T>

跟踪函数,用于检查数据变化的差异。类似于 ngFortrackBy 函数。 可以优化行操作,方法是根据该函数处理后的数据来标识一行,以了解该行是否应添加/删除/移动。接受带两个参数 indexitem 的函数。

Tracking function that will be used to check the differences in data changes. Used similarly to ngFor trackBy function. Optimize row operations by identifying a row based on its data relative to the function to know if a row should be added/removed/moved. Accepts a function that takes two parameters, index and item.

needsPositionStickyOnElement: false

改写在 CdkTable 每个粘性单元元素上添加 position: sticky 的需求。

Overrides the need to add position: sticky on every sticky cell element in CdkTable.

stickyCssClass: 'mat-table-sticky'

CdkTable 设置的粘性 CSS 类。

Overrides the sticky CSS class set by the CdkTable.

方法
addColumnDef

添加一个未包含在内容子组件中的列定义。

Adds a column definition that was not included as part of the content children.

参数

Parameters

columnDef

CdkColumnDef
addFooterRowDef

添加一个未包含在内容子组件中的表尾行定义。

Adds a footer row definition that was not included as part of the content children.

参数

Parameters

footerRowDef

CdkFooterRowDef
addHeaderRowDef

添加一个未包含在内容子组件中的表头行定义。

Adds a header row definition that was not included as part of the content children.

参数

Parameters

headerRowDef

CdkHeaderRowDef
addRowDef

添加一个未包含在内容子组件中的行定义。

Adds a row definition that was not included as part of the content children.

参数

Parameters

rowDef

CdkRowDef<T>
removeColumnDef

删除那些未包含在内容子组件中的列定义。

Removes a column definition that was not included as part of the content children.

参数

Parameters

columnDef

CdkColumnDef
removeFooterRowDef

删除一个未包含在内容子组件中的表尾行定义。

Removes a footer row definition that was not included as part of the content children.

参数

Parameters

footerRowDef

CdkFooterRowDef
removeHeaderRowDef

删除那些未包含在内容子组件中的表头行定义。

Removes a header row definition that was not included as part of the content children.

参数

Parameters

headerRowDef

CdkHeaderRowDef
removeRowDef

删除那些未包含在内容子组件中的行定义。

Removes a row definition that was not included as part of the content children.

参数

Parameters

rowDef

CdkRowDef<T>
renderRows

根据表格中最新的数据集来渲染行,这些数据既可以直接输入,也可以从一个可观察的流中检索出来(直接获取或从 DataSource 获取)。检查自上次 diff 之后的数据差异,以便只进行必要的修改(添加/删除/移动行)。

Renders rows based on the table's latest set of data, which was either provided directly as an input or retrieved through an Observable stream (directly or from a DataSource). Checks for differences in the data since the last diff to perform only the necessary changes (add/remove/move rows).

如果表格的数据源是 DataSource 或者 Observable,每当提供的 Observable 流发出一个新的数据数组时,都会自动调用它。如果你的数据是数组,那么就需要手动调用这个函数来渲染任何变化。

If the table's data source is a DataSource or Observable, this will be invoked automatically each time the provided Observable stream emits a new data array. Otherwise if your data is an array, this function will need to be called to render any changes.

setNoDataRow

设置一个没有包含在内容子组件中的无数据行定义。

Sets a no data row definition that was not included as a part of the content children.

参数

Parameters

noDataRow

CdkNoDataRow
updateStickyColumnStyles

更新列的粘性样式。首先,对于已粘附在左右两侧的单元格,重置所有已应用的样式。然后,根据每一行中每个单元格的列定义,评估哪些单元格需要粘附在左侧或右侧。当列定义的粘性属性发生变化时,会自动调用它。如果单元格内容在上述事件之外发生了变化,可以手动调用。

Updates the column sticky styles. First resets all applied styles with respect to the cells sticking to the left and right. Then sticky styles are added for the left and right according to the column definitions for each cell in each row. This is automatically called when the data source provides a new set of data or when a column definition changes its sticky input. May be called manually for cases where the cell content changes outside of these events.

updateStickyFooterRowStyles

更新表尾的粘性样式。首先,对于已粘附在底部的单元格,重置所有已应用的样式。然后,评估哪些单元格需要粘附在底部。当表尾行所显示的一组列发生变化时,或者其粘性属性发生变化时,会自动调用它。如果单元格内容在上述事件之外发生了变化,可以手动调用。

Updates the footer sticky styles. First resets all applied styles with respect to the cells sticking to the bottom. Then, evaluating which cells need to be stuck to the bottom. This is automatically called when the footer row changes its displayed set of columns, or if its sticky input changes. May be called manually for cases where the cell content changes outside of these events.

updateStickyHeaderRowStyles

更新表头的粘性样式。首先,对于已粘附在顶部的单元格,重置所有已应用的样式。然后,评估哪些单元格需要粘附在上面。当表头行所显示的一组列发生变化时,或者其粘性属性发生变化时,会自动调用它。如果单元格内容在上述事件之外发生了变化,可以手动调用。

Updates the header sticky styles. First resets all applied styles with respect to the cells sticking to the top. Then, evaluating which cells need to be stuck to the top. This is automatically called when the header row changes its displayed set of columns, or if its sticky input changes. May be called manually for cases where the cell content changes outside of these events.

mat-table 的表头行定义。存放表头行的模板和其他表头属性,比如要显示的列。

Header row definition for the mat-table. Captures the header row's template and other header properties such as the columns to display.

选择器: [matHeaderRowDef]
属性
名称 描述
@Input( matHeaderRowDef)

columns: Iterable<string>

要在行上显示的列。

The columns to be displayed on this row.

@Input( matHeaderRowDefSticky)

sticky: boolean

是否应该使用粘性定位。

Whether sticky positioning should be applied.

方法
extractCellTemplate

从提供的列定义中获取对此行的定义有用的相关单元格模板。

Gets this row def's relevant cell template from the provided column def.

参数

Parameters

column

CdkColumnDef

返回值

Returns

TemplateRef<any>
getColumnsDiff

返回当前列和最后一个差分过的列之间的差异,如果没有差别,则返回 null。

Returns the difference between the current columns and the columns from the last diff, or null if there is no difference.

返回值

Returns

IterableChanges<any> | null
hasStickyChanged

此粘性组件的值是否自上次调用后发生了变化。

Whether the sticky value has changed since this was last called.

返回值

Returns

boolean
resetStickyChanged

对于粘性状态已被使用且未经检查的情况,重置脏检查。

Resets the dirty check for cases where the sticky state has been used without checking.

mat-table 的表尾行定义。存放表尾行的模板和其他表尾属性,比如要显示的列。

Footer row definition for the mat-table. Captures the footer row's template and other footer properties such as the columns to display.

选择器: [matFooterRowDef]
属性
名称 描述
@Input( matFooterRowDef)

columns: Iterable<string>

要在行上显示的列。

The columns to be displayed on this row.

@Input( matFooterRowDefSticky)

sticky: boolean

是否应该使用粘性定位。

Whether sticky positioning should be applied.

方法
extractCellTemplate

从提供的列定义中获取对此行的定义有用的相关单元格模板。

Gets this row def's relevant cell template from the provided column def.

参数

Parameters

column

CdkColumnDef

返回值

Returns

TemplateRef<any>
getColumnsDiff

返回当前列和最后一个差分过的列之间的差异,如果没有差别,则返回 null。

Returns the difference between the current columns and the columns from the last diff, or null if there is no difference.

返回值

Returns

IterableChanges<any> | null
hasStickyChanged

此粘性组件的值是否自上次调用后发生了变化。

Whether the sticky value has changed since this was last called.

返回值

Returns

boolean
resetStickyChanged

对于粘性状态已被使用且未经检查的情况,重置脏检查。

Resets the dirty check for cases where the sticky state has been used without checking.

mat-table 的数据行定义。 存放数据行的模板和其他属性,比如要显示的列和描述何时应该使用该行的谓词。

Data row definition for the mat-table. Captures the data row's template and other properties such as the columns to display and a when predicate that describes when this row should be used.

选择器: [matRowDef]
属性
名称 描述
@Input( matRowDefColumns)

columns: Iterable<string>

要在行上显示的列。

The columns to be displayed on this row.

@Input( matRowDefWhen)

when: (index: number, rowData: T) => boolean

如果要把这个行模板用于所提供的索引和行数据,该函数应返回 true。如果未定义,那么当该函数对该数据返回 true 时,该行将被认为是默认的行模板。对于每一行,必须至少有一个函数能通过或者为 undefined 以便作为默认值。

Function that should return true if this row template should be used for the provided index and row data. If left undefined, this row will be considered the default row template to use when no other when functions return true for the data. For every row, there must be at least one when function that passes or an undefined to default.

方法
extractCellTemplate

从提供的列定义中获取对此行的定义有用的相关单元格模板。

Gets this row def's relevant cell template from the provided column def.

参数

Parameters

column

CdkColumnDef

返回值

Returns

TemplateRef<any>
getColumnsDiff

返回当前列和最后一个差分过的列之间的差异,如果没有差别,则返回 null。

Returns the difference between the current columns and the columns from the last diff, or null if there is no difference.

返回值

Returns

IterableChanges<any> | null

包含单元格出口地标的表头模板容器。添加合适的类和角色。

Header template container that contains the cell outlet. Adds the right class and role.

选择器: mat-header-row tr[mat-header-row]
导出为: matHeaderRow

包含单元格出口地标的表尾模板容器。添加合适的类和角色。

Footer template container that contains the cell outlet. Adds the right class and role.

选择器: mat-footer-row tr[mat-footer-row]
导出为: matFooterRow

包含单元格出口地标的数据行模板容器。添加合适的类和角色。

Data row template container that contains the cell outlet. Adds the right class and role.

选择器: mat-row tr[mat-row]
导出为: matRow

当表中没有数据时,可以用来显示一条消息的行。

Row that can be used to display a message when no data is shown in the table.

选择器: ng-template[matNoDataRow]
属性
名称 描述

templateRef: TemplateRef<any>

只显示表头行和行单元格的文本内容的列。假设该表正在使用原生表格实现( <table> )。

Column that simply shows text content for the header and row cells. Assumes that the table is using the native table implementation (<table>).

默认情况下,该列的名称就是表头文本和数据属性访问器。输入属性 headerText 可以改写表头文本。输入属性 dataAccessor 可以改写单元格的值。 输入属性 justify 把文本对齐方式修改为对齐到开头或结尾。

By default, the name of this column will be the header text and data property accessor. The header text can be overridden with the headerText input. Cell values can be overridden with the dataAccessor input. Change the text justification to the start or end using the justify input.

选择器: mat-text-column
属性
名称 描述
@Input()

dataAccessor: (data: T, name: string) => string

访问器函数用来检索为要每个单元格渲染的数据。如果未设置此属性,数据单元格将渲染数据属性中与该列名匹配的值。 例如,如果列的名字是 id ,那么渲染的值就是 data 的 id 属性定义的值。

Accessor function to retrieve the data rendered for each cell. If this property is not set, the data cells will render the value found in the data's property matching the column's name. For example, if the column is named id, then the rendered value will be value defined by the data's id property.

@Input()

headerText: string

要作为列表头的文本标签。如果未设置此属性,则表头文本默认使用列名的首字母大写形式。

Text label that should be used for the column header. If this property is not set, the header text will default to the column name with its first letter capitalized.

@Input()

justify: 'start' | 'end'

单元格中值的对齐方式。

Alignment of the cell values.

@Input()

name: string

要用来引用这个列的列名。

Column name that should be used to reference this column.

可接受客户端数据的数据源,包括原生支持的过滤、排序(使用 MatSort)和分页(使用 MatPaginator)。

Data source that accepts a client-side data array and includes native support of filtering, sorting (using MatSort), and pagination (using MatPaginator).

可以通过改写 sortingDataAccessor 来进行自定义排序,它定义了要如何访问数据属性。 还允许通过改写 filterTermAccessor 来自定义过滤器,它定义了要如何将行数据转换成字符串以进行过滤匹配。

Allows for sort customization by overriding sortingDataAccessor, which defines how data properties are accessed. Also allows for filter customization by overriding filterTermAccessor, which defines how row data is converted to a string for filter matching.

注意:这个类是一个简单的数据源,可以帮助你入门。因此,它无法处理某些更高级的案例,比如提供强大的 i18n 支持或服务器端交互。 如果你的应用需要支持更高级的用例,可以考虑实现自己的 DataSource

Note: This class is meant to be a simple data source to help you get started. As such it isn't equipped to handle some more advanced cases like robust i18n support or server-side interactions. If your app needs to support more advanced use cases, consider implementing your own DataSource.

属性
名称 描述

data: T[]

要由表格渲染的数据数组,其中每个对象代表一行。

Array of data that should be rendered by the table, where each object represents one row.

filter: string

要用来从数据数组中过滤对象的过滤器关键词。 要改写数据对象与此过滤器字符串的匹配方式,请为 filterPredicate 提供一个自定义函数。

Filter term that should be used to filter out objects from the data array. To override how data objects match to this filter string, provide a custom function for filterPredicate.

filterPredicate: ((data: T, filter: string) => boolean)

检查数据对象是否与数据源的过滤字符串匹配。默认情况下,会把每个数据对象都转换为其属性的字符串,如果该过滤器在该字符串中至少出现过一次,则返回 true。默认情况下,会修剪掉过滤字符串的空白,并且匹配时不区分大小写。可以改写为过滤器匹配算法的自定义实现。

Checks if a data object matches the data source's filter string. By default, each data object is converted to a string of its properties and returns true if the filter has at least one occurrence in that string. By default, the filter string has its whitespace trimmed and the match is case-insensitive. May be overridden for a custom implementation of filter matching.

filteredData: T[]

通过过滤器字符串过滤过的数据集,如果没有过滤器,则全是数据。 需要知道表格所展现的数据集时,这非常有用。比如,'selectAll()' 函数可能会想给用户展示一组过滤过的数据,而不是所有的数据。

The filtered set of data that has been matched by the filter string, or all the data if there is no filter. Useful for knowing the set of data the table represents. For example, a 'selectAll()' function would likely want to select the set of filtered data shown to the user rather than all the data.

paginator: P | null

该表格使用的 MatPaginator 组件实例,用来控制要显示哪页数据。MatPaginator 发出的页面更改会触发表格渲染数据的更新。

Instance of the MatPaginator component used by the table to control what page of the data is displayed. Page changes emitted by the MatPaginator will trigger an update to the table's rendered data.

注意,数据源会使用此分页器的属性来计算应该显示哪个页面的数据。如果分页器要通过模板输入接收其属性,比如 [pageLength]=100 或者 [pageIndex]=1 ,那就要确保此分页器的视图已经初始化了,然后再赋值给这个数据源。

Note that the data source uses the paginator's properties to calculate which page of data should be displayed. If the paginator receives its properties as template inputs, e.g. [pageLength]=100 or [pageIndex]=1, then be sure that the paginator's view has been initialized before assigning it to this data source.

sort: MatSort | null

该表格使用 MatSort 指令的实例来控制它的排序。 MatSort 发出的排序变化会触发对该表格所渲染数据的更新。

Instance of the MatSort directive used by the table to control its sorting. Sort changes emitted by the MatSort will trigger an update to the table's rendered data.

sortData: ((data: T[], sort: MatSort) => T[])

根据 MatSort 的状态获取一个数据数组的已排序副本。在对已过滤的数据进行更改或从 MatSort 发出排序更改时调用。 默认情况下,使用该函数检索主动排序及其方向,并借助 sortingDataAccessor 检索数据来进行比较。可以改写为自定义的数据排序实现。

Gets a sorted copy of the data array based on the state of the MatSort. Called after changes are made to the filtered data or when sort changes are emitted from MatSort. By default, the function retrieves the active sort and its direction and compares data by retrieving data using the sortingDataAccessor. May be overridden for a custom implementation of data ordering.

sortingDataAccessor: ((data: T, sortHeaderId: string) => string | number)

数据访问器函数,用于访问数据属性,以便通过默认的 sortData 函数进行排序。 这个默认函数假设排序头的 ID(默认为列名)与数据的属性相匹配(比如列 Xyz 对应 data['Xyz'])。可以为不同的行为设置同一个自定义函数。

Data accessor function that is used for accessing data properties for sorting through the default sortData function. This default function assumes that the sort header IDs (which defaults to the column name) matches the data's properties (e.g. column Xyz represents data['Xyz']). May be set to a custom function for different behavior.

Angular Material table-testing API 参考文档

import {MatTableHarness} from '@angular/material/table/testing';

在测试中用来与标准 mat-table 进行交互的测试工具。

Harness for interacting with a standard mat-table in tests.

方法
异步
getAllChildLoaders

参数

Parameters

selector

S

返回值

Returns

Promise<HarnessLoader[]>
异步
getAllHarnesses

参数

Parameters

query

HarnessQuery<T>

返回值

Returns

Promise<T[]>
异步
getCellTextByColumnName

Gets the text inside the entire table organized by columns.

返回值

Returns

Promise<MatTableHarnessColumnsText>
异步
getCellTextByIndex

Gets the text inside the entire table organized by rows.

返回值

Returns

Promise<string[][]>
异步
getChildLoader

参数

Parameters

selector

S

返回值

Returns

Promise<HarnessLoader>
异步
getFooterRows

Gets all of the footer rows in a table.

参数

Parameters

filter

RowHarnessFilters = {}

返回值

Returns

Promise<MatFooterRowHarness[]>
异步
getHarness

参数

Parameters

query

HarnessQuery<T>

返回值

Returns

Promise<T>
异步
getHeaderRows

Gets all of the header rows in a table.

参数

Parameters

filter

RowHarnessFilters = {}

返回值

Returns

Promise<MatHeaderRowHarness[]>
异步
getRows

Gets all of the regular data rows in a table.

参数

Parameters

filter

RowHarnessFilters = {}

返回值

Returns

Promise<MatRowHarness[]>
异步
host

获取一个代表该组件宿主元素的 TestElementPromise

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

返回值

Returns

Promise<TestElement>

Harness for interacting with a standard Angular Material table row.

方法
异步
getCellTextByColumnName

Gets the text inside the row organized by columns.

返回值

Returns

Promise<MatRowHarnessColumnsText>
异步
getCellTextByIndex

Gets the text of the cells in the row.

参数

Parameters

filter

CellHarnessFilters = {}

返回值

Returns

Promise<string[]>
异步
getCells

Gets a list of MatCellHarness for all cells in the row.

参数

Parameters

filter

CellHarnessFilters = {}

返回值

Returns

Promise<MatCellHarness[]>
异步
host

获取一个代表该组件宿主元素的 TestElementPromise

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

返回值

Returns

Promise<TestElement>

Harness for interacting with a standard Angular Material table header row.

方法
异步
getCellTextByColumnName

Gets the text inside the header row organized by columns.

返回值

Returns

Promise<MatRowHarnessColumnsText>
异步
getCellTextByIndex

Gets the text of the cells in the header row.

参数

Parameters

filter

CellHarnessFilters = {}

返回值

Returns

Promise<string[]>
异步
getCells

Gets a list of MatHeaderCellHarness for all cells in the row.

参数

Parameters

filter

CellHarnessFilters = {}

返回值

Returns

Promise<MatHeaderCellHarness[]>
异步
host

获取一个代表该组件宿主元素的 TestElementPromise

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

返回值

Returns

Promise<TestElement>

Harness for interacting with a standard Angular Material table footer row.

方法
异步
getCellTextByColumnName

Gets the text inside the footer row organized by columns.

返回值

Returns

Promise<MatRowHarnessColumnsText>
异步
getCellTextByIndex

Gets the text of the cells in the footer row.

参数

Parameters

filter

CellHarnessFilters = {}

返回值

Returns

Promise<string[]>
异步
getCells

Gets a list of MatFooterCellHarness for all cells in the row.

参数

Parameters

filter

CellHarnessFilters = {}

返回值

Returns

Promise<MatFooterCellHarness[]>
异步
host

获取一个代表该组件宿主元素的 TestElementPromise

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

返回值

Returns

Promise<TestElement>

Harness for interacting with a standard Angular Material table cell.

方法
异步
getAllChildLoaders

参数

Parameters

selector

S

返回值

Returns

Promise<HarnessLoader[]>
异步
getAllHarnesses

参数

Parameters

query

HarnessQuery<T>

返回值

Returns

Promise<T[]>
异步
getChildLoader

参数

Parameters

selector

S

返回值

Returns

Promise<HarnessLoader>
异步
getColumnName

Gets the name of the column that the cell belongs to.

返回值

Returns

Promise<string>
异步
getHarness

参数

Parameters

query

HarnessQuery<T>

返回值

Returns

Promise<T>
异步
getText

Gets the cell's text.

返回值

Returns

Promise<string>
异步
host

获取一个代表该组件宿主元素的 TestElementPromise

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

返回值

Returns

Promise<TestElement>

Harness for interacting with a standard Angular Material table header cell.

方法
异步
getAllChildLoaders

参数

Parameters

selector

S

返回值

Returns

Promise<HarnessLoader[]>
异步
getAllHarnesses

参数

Parameters

query

HarnessQuery<T>

返回值

Returns

Promise<T[]>
异步
getChildLoader

参数

Parameters

selector

S

返回值

Returns

Promise<HarnessLoader>
异步
getColumnName

Gets the name of the column that the cell belongs to.

返回值

Returns

Promise<string>
异步
getHarness

参数

Parameters

query

HarnessQuery<T>

返回值

Returns

Promise<T>
异步
getText

Gets the cell's text.

返回值

Returns

Promise<string>
异步
host

获取一个代表该组件宿主元素的 TestElementPromise

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

返回值

Returns

Promise<TestElement>

Harness for interacting with a standard Angular Material table footer cell.

方法
异步
getAllChildLoaders

参数

Parameters

selector

S

返回值

Returns

Promise<HarnessLoader[]>
异步
getAllHarnesses

参数

Parameters

query

HarnessQuery<T>

返回值

Returns

Promise<T[]>
异步
getChildLoader

参数

Parameters

selector

S

返回值

Returns

Promise<HarnessLoader>
异步
getColumnName

Gets the name of the column that the cell belongs to.

返回值

Returns

Promise<string>
异步
getHarness

参数

Parameters

query

HarnessQuery<T>

返回值

Returns

Promise<T>
异步
getText

Gets the cell's text.

返回值

Returns

Promise<string>
异步
host

获取一个代表该组件宿主元素的 TestElementPromise

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

返回值

Returns

Promise<TestElement>

Text extracted from a table organized by columns.

方法
__index

参数

Parameters

columnName

string

返回值

Returns

{ text: string[]; headerText: string[]; footerText: string[]; }

Text extracted from a table row organized by columns.

方法
__index

参数

Parameters

columnName

string

返回值

Returns

string

A set of criteria that can be used to filter a list of cell harness instances.

属性
名称 描述

columnName: string | RegExp

Only find instances whose column name matches the given value.

text: string | RegExp

只查找其文本内容匹配指定值的实例。

Only find instances whose text matches the given value.

A set of criteria that can be used to filter a list of row harness instances.

A set of criteria that can be used to filter a list of table harness instances.