File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
src/material-examples/table-selection Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 55 < th mat-header-cell *matHeaderCellDef >
66 < mat-checkbox (change) ="$event ? masterToggle() : null "
77 [checked] ="selection.hasValue() && isAllSelected() "
8- [indeterminate] ="selection.hasValue() && !isAllSelected() ">
8+ [indeterminate] ="selection.hasValue() && !isAllSelected() "
9+ [aria-label] ="checkboxLabel() ">
910 </ mat-checkbox >
1011 </ th >
1112 < td mat-cell *matCellDef ="let row ">
1213 < mat-checkbox (click) ="$event.stopPropagation() "
1314 (change) ="$event ? selection.toggle(row) : null "
14- [checked] ="selection.isSelected(row) ">
15+ [checked] ="selection.isSelected(row) "
16+ [aria-label] ="checkboxLabel(row) ">
1517 </ mat-checkbox >
1618 </ td >
1719 </ ng-container >
Original file line number Diff line number Diff line change @@ -48,4 +48,12 @@ export class TableSelectionExample {
4848 this . selection . clear ( ) :
4949 this . dataSource . data . forEach ( row => this . selection . select ( row ) ) ;
5050 }
51+
52+ /** The label for the checkbox on the passed row */
53+ checkboxLabel ( row ?: PeriodicElement ) : string {
54+ if ( ! row ) {
55+ return `${ this . isAllSelected ( ) ? 'select' : 'deselect' } all` ;
56+ }
57+ return `${ this . selection . isSelected ( row ) ? 'deselect' : 'select' } row ${ row . position + 1 } ` ;
58+ }
5159}
You can’t perform that action at this time.
0 commit comments