diff --git a/src/material-examples/table-selection/table-selection-example.html b/src/material-examples/table-selection/table-selection-example.html index a22d56266de6..9bf76f15a326 100644 --- a/src/material-examples/table-selection/table-selection-example.html +++ b/src/material-examples/table-selection/table-selection-example.html @@ -5,13 +5,15 @@ + [indeterminate]="selection.hasValue() && !isAllSelected()" + [aria-label]="checkboxLabel()"> + [checked]="selection.isSelected(row)" + [aria-label]="checkboxLabel(row)"> diff --git a/src/material-examples/table-selection/table-selection-example.ts b/src/material-examples/table-selection/table-selection-example.ts index 153367376587..2b760109fa28 100644 --- a/src/material-examples/table-selection/table-selection-example.ts +++ b/src/material-examples/table-selection/table-selection-example.ts @@ -48,4 +48,12 @@ export class TableSelectionExample { this.selection.clear() : this.dataSource.data.forEach(row => this.selection.select(row)); } + + /** The label for the checkbox on the passed row */ + checkboxLabel(row?: PeriodicElement): string { + if (!row) { + return `${this.isAllSelected() ? 'select' : 'deselect'} all`; + } + return `${this.selection.isSelected(row) ? 'deselect' : 'select'} row ${row.position + 1}`; + } }