_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
components/src/components-examples/material/table/index.ts_0_2931
export {TableFlexBasicExample} from './table-flex-basic/table-flex-basic-example'; export {TableBasicExample} from './table-basic/table-basic-example'; export {TableDynamicColumnsExample} from './table-dynamic-columns/table-dynamic-columns-example'; export {TableExpandableRowsExample} from './table-expandable-rows/table-expandable-rows-example'; export {TableFilteringExample} from './table-filtering/table-filtering-example'; export {TableFooterRowExample} from './table-footer-row/table-footer-row-example'; export {TableHttpExample} from './table-http/table-http-example'; export {TableMultipleHeaderFooterExample} from './table-multiple-header-footer/table-multiple-header-footer-example'; export {TableMultipleRowTemplateExample} from './table-multiple-row-template/table-multiple-row-template-example'; export {TableOverviewExample} from './table-overview/table-overview-example'; export {TablePaginationExample} from './table-pagination/table-pagination-example'; export {TableRowContextExample} from './table-row-context/table-row-context-example'; export {TableSelectionExample} from './table-selection/table-selection-example'; export {TableSortingExample} from './table-sorting/table-sorting-example'; export {TableStickyColumnsExample} from './table-sticky-columns/table-sticky-columns-example'; export {TableStickyComplexFlexExample} from './table-sticky-complex-flex/table-sticky-complex-flex-example'; export {TableStickyComplexExample} from './table-sticky-complex/table-sticky-complex-example'; export {TableStickyFooterExample} from './table-sticky-footer/table-sticky-footer-example'; export {TableStickyHeaderExample} from './table-sticky-header/table-sticky-header-example'; export {TableTextColumnAdvancedExample} from './table-text-column-advanced/table-text-column-advanced-example'; export {TableTextColumnExample} from './table-text-column/table-text-column-example'; export {TableWrappedExample, WrapperTable} from './table-wrapped/table-wrapped-example'; export {TableReorderableExample} from './table-reorderable/table-reorderable-example'; export {TableRecycleRowsExample} from './table-recycle-rows/table-recycle-rows-example'; export {TableHarnessExample} from './table-harness/table-harness-example'; export {TableWithRipplesExample} from './table-with-ripples/table-with-ripples-example'; export {TableColumnStylingExample} from './table-column-styling/table-column-styling-example'; export {TableRowBindingExample} from './table-row-binding/table-row-binding-example'; export {TableDynamicArrayDataExample} from './table-dynamic-array-data/table-dynamic-array-data-example'; export {TableDynamicObservableDataExample} from './table-dynamic-observable-data/table-dynamic-observable-data-example'; export {TableGeneratedColumnsExample} from './table-generated-columns/table-generated-columns-example'; export {TableFlexLargeRowExample} from './table-flex-large-row/table-flex-large-row-example';
{ "end_byte": 2931, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/index.ts" }
components/src/components-examples/material/table/table-multiple-row-template/table-multiple-row-template-example.css_0_25
table { width: 100%; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-multiple-row-template/table-multiple-row-template-example.css" }
components/src/components-examples/material/table/table-multiple-row-template/table-multiple-row-template-example.ts_0_2023
import {Component} from '@angular/core'; import {MatTableDataSource, MatTableModule} from '@angular/material/table'; /** * @title Table with multiple row template */ @Component({ selector: 'table-multiple-row-template-example', styleUrls: ['table-multiple-row-template-example.css'], templateUrl: 'table-multiple-row-template-example.html', imports: [MatTableModule], }) export class TableMultipleRowTemplateExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA); } export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, {position: 11, name: 'Sodium', weight: 22.9897, symbol: 'Na'}, {position: 12, name: 'Magnesium', weight: 24.305, symbol: 'Mg'}, {position: 13, name: 'Aluminum', weight: 26.9815, symbol: 'Al'}, {position: 14, name: 'Silicon', weight: 28.0855, symbol: 'Si'}, {position: 15, name: 'Phosphorus', weight: 30.9738, symbol: 'P'}, {position: 16, name: 'Sulfur', weight: 32.065, symbol: 'S'}, {position: 17, name: 'Chlorine', weight: 35.453, symbol: 'Cl'}, {position: 18, name: 'Argon', weight: 39.948, symbol: 'Ar'}, {position: 19, name: 'Potassium', weight: 39.0983, symbol: 'K'}, {position: 20, name: 'Calcium', weight: 40.078, symbol: 'Ca'}, ];
{ "end_byte": 2023, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-multiple-row-template/table-multiple-row-template-example.ts" }
components/src/components-examples/material/table/table-multiple-row-template/table-multiple-row-template-example.html_0_1421
<div class="mat-elevation-z8"> <table mat-table [dataSource]="dataSource" multiTemplateDataRows> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef>No.</th> <td mat-cell *matCellDef="let element">{{element.position}}</td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef>Name</th> <td mat-cell *matCellDef="let element">{{element.name}}</td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef>Weight</th> <td mat-cell *matCellDef="let element">{{element.weight}}</td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef>Symbol</th> <td mat-cell *matCellDef="let element">{{element.symbol}}</td> </ng-container> <!-- Secondary Column --> <ng-container matColumnDef="secondary"> <td mat-cell [attr.colspan]="displayedColumns.length" *matCellDef="let element"> Secondary row for the element {{element.name}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: ['secondary'];"></tr> </table> </div>
{ "end_byte": 1421, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-multiple-row-template/table-multiple-row-template-example.html" }
components/src/components-examples/material/table/table-filtering/table-filtering-example.html_0_1371
<mat-form-field> <mat-label>Filter</mat-label> <input matInput (keyup)="applyFilter($event)" placeholder="Ex. ium" #input> </mat-form-field> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <!-- Row shown when there is no matching data. --> <tr class="mat-row" *matNoDataRow> <td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td> </tr> </table>
{ "end_byte": 1371, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-filtering/table-filtering-example.html" }
components/src/components-examples/material/table/table-filtering/table-filtering-example.css_0_100
/* Structure */ table { width: 100%; } .mat-mdc-form-field { font-size: 14px; width: 100%; }
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-filtering/table-filtering-example.css" }
components/src/components-examples/material/table/table-filtering/table-filtering-example.ts_0_1609
import {Component} from '@angular/core'; import {MatTableDataSource, MatTableModule} from '@angular/material/table'; import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Table with filtering */ @Component({ selector: 'table-filtering-example', styleUrl: 'table-filtering-example.css', templateUrl: 'table-filtering-example.html', imports: [MatFormFieldModule, MatInputModule, MatTableModule], }) export class TableFilteringExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = new MatTableDataSource(ELEMENT_DATA); applyFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; this.dataSource.filter = filterValue.trim().toLowerCase(); } }
{ "end_byte": 1609, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-filtering/table-filtering-example.ts" }
components/src/components-examples/material/table/table-recycle-rows/table-recycle-rows-example.css_0_34
.example-table { width: 100%; }
{ "end_byte": 34, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-recycle-rows/table-recycle-rows-example.css" }
components/src/components-examples/material/table/table-recycle-rows/table-recycle-rows-example.ts_0_1286
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Table that uses the recycle view repeater strategy. */ @Component({ selector: 'table-recycle-rows-example', styleUrl: 'table-recycle-rows-example.css', templateUrl: 'table-recycle-rows-example.html', imports: [MatTableModule], }) export class TableRecycleRowsExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA; }
{ "end_byte": 1286, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-recycle-rows/table-recycle-rows-example.ts" }
components/src/components-examples/material/table/table-recycle-rows/table-recycle-rows-example.html_0_1064
<table class="example-table mat-elevation-z8" mat-table recycleRows [dataSource]="dataSource"> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 1064, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-recycle-rows/table-recycle-rows-example.html" }
components/src/components-examples/material/table/table-flex-large-row/table-flex-large-row-example.ts_0_1311
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Flex table where one column's cells has a greater height than others. */ @Component({ selector: 'table-flex-large-row-example', styleUrl: 'table-flex-large-row-example.css', templateUrl: 'table-flex-large-row-example.html', imports: [MatTableModule], }) export class TableFlexLargeRowExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA; }
{ "end_byte": 1311, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-flex-large-row/table-flex-large-row-example.ts" }
components/src/components-examples/material/table/table-flex-large-row/table-flex-large-row-example.html_0_1097
<mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <!-- Position Column --> <ng-container matColumnDef="position"> <mat-header-cell *matHeaderCellDef> No. </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.position}} </mat-cell> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <mat-header-cell *matHeaderCellDef> Name </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.name}} </mat-cell> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <mat-header-cell *matHeaderCellDef> Weight </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.weight}} </mat-cell> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <mat-header-cell *matHeaderCellDef> Symbol </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.symbol}} </mat-cell> </ng-container> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> </mat-table>
{ "end_byte": 1097, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-flex-large-row/table-flex-large-row-example.html" }
components/src/components-examples/material/table/table-flex-large-row/table-flex-large-row-example.css_0_112
.mat-mdc-table { width: 100%; max-height: 500px; overflow: auto; } .mat-column-name { height: 100px; }
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-flex-large-row/table-flex-large-row-example.css" }
components/src/components-examples/material/table/table-row-context/table-row-context-example.css_0_25
table { width: 100%; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-row-context/table-row-context-example.css" }
components/src/components-examples/material/table/table-row-context/table-row-context-example.html_0_1595
<table mat-table [dataSource]="data" class="mat-elevation-z8"> <!-- Implicit Column --> <ng-container matColumnDef="$implicit"> <th mat-header-cell *matHeaderCellDef> $implicit </th> <td mat-cell *matCellDef="let data"> {{data}} </td> </ng-container> <!-- Index Column --> <ng-container matColumnDef="index"> <th mat-header-cell *matHeaderCellDef> index </th> <td mat-cell *matCellDef="let index = index"> {{index}} </td> </ng-container> <!-- Count Column --> <ng-container matColumnDef="count"> <th mat-header-cell *matHeaderCellDef> count </th> <td mat-cell *matCellDef="let count = count"> {{count}} </td> </ng-container> <!-- First Column --> <ng-container matColumnDef="first"> <th mat-header-cell *matHeaderCellDef> first </th> <td mat-cell *matCellDef="let first = first"> {{first}} </td> </ng-container> <!-- Last Column --> <ng-container matColumnDef="last"> <th mat-header-cell *matHeaderCellDef> last </th> <td mat-cell *matCellDef="let last = last"> {{last}} </td> </ng-container> <!-- Even Column --> <ng-container matColumnDef="even"> <th mat-header-cell *matHeaderCellDef> even </th> <td mat-cell *matCellDef="let even = even"> {{even}} </td> </ng-container> <!-- Odd Column --> <ng-container matColumnDef="odd"> <th mat-header-cell *matHeaderCellDef> odd </th> <td mat-cell *matCellDef="let odd = odd"> {{odd}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 1595, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-row-context/table-row-context-example.html" }
components/src/components-examples/material/table/table-row-context/table-row-context-example.ts_0_535
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; /** * @title Table showing each row context properties. */ @Component({ selector: 'table-row-context-example', styleUrl: 'table-row-context-example.css', templateUrl: 'table-row-context-example.html', imports: [MatTableModule], }) export class TableRowContextExample { displayedColumns: string[] = ['$implicit', 'index', 'count', 'first', 'last', 'even', 'odd']; data: string[] = ['one', 'two', 'three', 'four', 'five']; }
{ "end_byte": 535, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-row-context/table-row-context-example.ts" }
components/src/components-examples/material/table/table-sticky-columns/table-sticky-columns-example.ts_0_1404
import {Component} from '@angular/core'; import {MatIconModule} from '@angular/material/icon'; import {MatTableModule} from '@angular/material/table'; /** * @title Table with sticky columns */ @Component({ selector: 'table-sticky-columns-example', styleUrl: 'table-sticky-columns-example.css', templateUrl: 'table-sticky-columns-example.html', imports: [MatTableModule, MatIconModule], }) export class TableStickyColumnsExample { displayedColumns = [ 'name', 'position', 'weight', 'symbol', 'position', 'weight', 'symbol', 'star', ]; dataSource = ELEMENT_DATA; } export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ];
{ "end_byte": 1404, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-columns/table-sticky-columns-example.ts" }
components/src/components-examples/material/table/table-sticky-columns/table-sticky-columns-example.css_0_412
.example-container { height: 400px; width: 550px; max-width: 100%; overflow: auto; } table { width: 800px; } td.mat-column-star { width: 20px; padding-right: 8px; } th.mat-column-position, td.mat-column-position { padding-left: 8px; } .mat-mdc-table-sticky-border-elem-right { border-left: 1px solid #e0e0e0; } .mat-mdc-table-sticky-border-elem-left { border-right: 1px solid #e0e0e0; }
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-columns/table-sticky-columns-example.css" }
components/src/components-examples/material/table/table-sticky-columns/table-sticky-columns-example.html_0_1418
<section class="example-container mat-elevation-z8" tabindex="0"> <table mat-table [dataSource]="dataSource"> <!-- Name Column --> <ng-container matColumnDef="name" sticky> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <!-- Star Column --> <ng-container matColumnDef="star" stickyEnd> <th mat-header-cell *matHeaderCellDef aria-label="row actions">&nbsp;</th> <td mat-cell *matCellDef="let element"> <mat-icon>more_vert</mat-icon> </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table> </section>
{ "end_byte": 1418, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-columns/table-sticky-columns-example.html" }
components/src/components-examples/material/table/table-text-column-advanced/table-text-column-advanced-example.html_0_675
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <mat-text-column name="position" [headerText]="headerText"></mat-text-column> <!-- Change the header text. --> <mat-text-column name="name" headerText="Element"></mat-text-column> <!-- Provide a data accessor for getting the cell text values. --> <mat-text-column name="weight" [dataAccessor]="getWeight"></mat-text-column> <!-- Justify the content of the cells to the cell end. --> <mat-text-column name="symbol" justify="end"></mat-text-column> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 675, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-text-column-advanced/table-text-column-advanced-example.html" }
components/src/components-examples/material/table/table-text-column-advanced/table-text-column-advanced-example.ts_0_1758
import {Component} from '@angular/core'; import {DecimalPipe} from '@angular/common'; import {MatTableDataSource, MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Use of 'mat-text-column' with various configurations of the interface. */ @Component({ selector: 'table-text-column-advanced-example', styleUrl: 'table-text-column-advanced-example.css', templateUrl: 'table-text-column-advanced-example.html', imports: [MatTableModule], }) export class TableTextColumnAdvancedExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = new MatTableDataSource(ELEMENT_DATA); headerText: string; decimalPipe = new DecimalPipe('en-US'); /** Data accessor function that transforms the weight value to have at most 2 decimal digits. */ getWeight = (data: PeriodicElement): string => { const result = this.decimalPipe.transform(data.weight, '1.0-2'); return result === null ? '' : result; }; }
{ "end_byte": 1758, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-text-column-advanced/table-text-column-advanced-example.ts" }
components/src/components-examples/material/table/table-text-column-advanced/table-text-column-advanced-example.css_0_25
table { width: 100%; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-text-column-advanced/table-text-column-advanced-example.css" }
components/src/components-examples/material/table/table-sticky-footer/table-sticky-footer-example.ts_0_933
import {Component} from '@angular/core'; import {CurrencyPipe} from '@angular/common'; import {MatTableModule} from '@angular/material/table'; export interface Transaction { item: string; cost: number; } /** * @title Table with a sticky footer */ @Component({ selector: 'table-sticky-footer-example', styleUrl: 'table-sticky-footer-example.css', templateUrl: 'table-sticky-footer-example.html', imports: [MatTableModule, CurrencyPipe], }) export class TableStickyFooterExample { displayedColumns = ['item', 'cost']; transactions: Transaction[] = [ {item: 'Beach ball', cost: 4}, {item: 'Towel', cost: 5}, {item: 'Frisbee', cost: 2}, {item: 'Sunscreen', cost: 4}, {item: 'Cooler', cost: 25}, {item: 'Swim suit', cost: 15}, ]; /** Gets the total cost of all transactions. */ getTotalCost() { return this.transactions.map(t => t.cost).reduce((acc, value) => acc + value, 0); } }
{ "end_byte": 933, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-footer/table-sticky-footer-example.ts" }
components/src/components-examples/material/table/table-sticky-footer/table-sticky-footer-example.html_0_936
<section class="example-container mat-elevation-z8" tabindex="0"> <table mat-table [dataSource]="transactions"> <!-- Item Column --> <ng-container matColumnDef="item"> <th mat-header-cell *matHeaderCellDef> Item </th> <td mat-cell *matCellDef="let transaction"> {{transaction.item}} </td> <td mat-footer-cell *matFooterCellDef> Total </td> </ng-container> <!-- Cost Column --> <ng-container matColumnDef="cost"> <th mat-header-cell *matHeaderCellDef> Cost </th> <td mat-cell *matCellDef="let transaction"> {{transaction.cost | currency}} </td> <td mat-footer-cell *matFooterCellDef> {{getTotalCost() | currency}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-footer-row *matFooterRowDef="displayedColumns; sticky: true"></tr> </table> </section>
{ "end_byte": 936, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-footer/table-sticky-footer-example.html" }
components/src/components-examples/material/table/table-sticky-footer/table-sticky-footer-example.css_0_192
.example-container { height: 270px; overflow: auto; } table { width: 100%; } tr.mat-mdc-footer-row { font-weight: bold; } .mat-mdc-table-sticky { border-top: 1px solid #e0e0e0; }
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-footer/table-sticky-footer-example.css" }
components/src/components-examples/material/table/table-reorderable/table-reorderable-example.ts_0_1491
import {Component} from '@angular/core'; import {CdkDragDrop, CdkDrag, CdkDropList, moveItemInArray} from '@angular/cdk/drag-drop'; import {MatTableModule} from '@angular/material/table'; /** * @title Table with re-orderable columns */ @Component({ selector: 'table-reorderable-example', templateUrl: './table-reorderable-example.html', styleUrl: './table-reorderable-example.css', imports: [MatTableModule, CdkDropList, CdkDrag], }) export class TableReorderableExample { columns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA; drop(event: CdkDragDrop<string[]>) { moveItemInArray(this.columns, event.previousIndex, event.currentIndex); } } export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ];
{ "end_byte": 1491, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-reorderable/table-reorderable-example.ts" }
components/src/components-examples/material/table/table-reorderable/table-reorderable-example.css_0_25
table { width: 100%; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-reorderable/table-reorderable-example.css" }
components/src/components-examples/material/table/table-reorderable/table-reorderable-example.html_0_1040
<table mat-table [dataSource]="dataSource" cdkDropList cdkDropListOrientation="horizontal" (cdkDropListDropped)="drop($event)"> <ng-container matColumnDef="position"> <th mat-header-cell cdkDrag *matHeaderCellDef> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <ng-container matColumnDef="name"> <th mat-header-cell cdkDrag *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <ng-container matColumnDef="weight"> <th mat-header-cell cdkDrag *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <ng-container matColumnDef="symbol"> <th mat-header-cell cdkDrag *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="columns"></tr> <tr mat-row *matRowDef="let row; columns: columns;"></tr> </table>
{ "end_byte": 1040, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-reorderable/table-reorderable-example.html" }
components/src/components-examples/material/table/table-basic/table-basic-example.html_0_1186
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <!--- Note that these columns can be defined in any order. The actual rendered columns are set as a property on the row definition" --> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 1186, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-basic/table-basic-example.html" }
components/src/components-examples/material/table/table-basic/table-basic-example.css_0_25
table { width: 100%; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-basic/table-basic-example.css" }
components/src/components-examples/material/table/table-basic/table-basic-example.ts_0_1240
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Basic use of `<table mat-table>` */ @Component({ selector: 'table-basic-example', styleUrl: 'table-basic-example.css', templateUrl: 'table-basic-example.html', imports: [MatTableModule], }) export class TableBasicExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA; }
{ "end_byte": 1240, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-basic/table-basic-example.ts" }
components/src/components-examples/material/table/table-flex-basic/table-flex-basic-example.ts_0_1273
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Basic use of `<mat-table>` (uses display flex) */ @Component({ selector: 'table-flex-basic-example', styleUrl: 'table-flex-basic-example.css', templateUrl: 'table-flex-basic-example.html', imports: [MatTableModule], }) export class TableFlexBasicExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA; }
{ "end_byte": 1273, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-flex-basic/table-flex-basic-example.ts" }
components/src/components-examples/material/table/table-flex-basic/table-flex-basic-example.css_0_25
table { width: 100%; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-flex-basic/table-flex-basic-example.css" }
components/src/components-examples/material/table/table-flex-basic/table-flex-basic-example.html_0_1097
<mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <!-- Position Column --> <ng-container matColumnDef="position"> <mat-header-cell *matHeaderCellDef> No. </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.position}} </mat-cell> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <mat-header-cell *matHeaderCellDef> Name </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.name}} </mat-cell> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <mat-header-cell *matHeaderCellDef> Weight </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.weight}} </mat-cell> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <mat-header-cell *matHeaderCellDef> Symbol </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.symbol}} </mat-cell> </ng-container> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> </mat-table>
{ "end_byte": 1097, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-flex-basic/table-flex-basic-example.html" }
components/src/components-examples/material/table/table-text-column/table-text-column-example.css_0_25
table { width: 100%; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-text-column/table-text-column-example.css" }
components/src/components-examples/material/table/table-text-column/table-text-column-example.ts_0_1360
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Use of `mat-text-column` which can be used for simple columns that only need to display * a text value for the header and cells. */ @Component({ selector: 'table-text-column-example', styleUrl: 'table-text-column-example.css', templateUrl: 'table-text-column-example.html', imports: [MatTableModule], }) export class TableTextColumnExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA; }
{ "end_byte": 1360, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-text-column/table-text-column-example.ts" }
components/src/components-examples/material/table/table-text-column/table-text-column-example.html_0_419
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <mat-text-column name="position"></mat-text-column> <mat-text-column name="name"></mat-text-column> <mat-text-column name="weight"></mat-text-column> <mat-text-column name="symbol"></mat-text-column> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 419, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-text-column/table-text-column-example.html" }
components/src/components-examples/material/table/table-with-ripples/table-with-ripples-example.html_0_444
<mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <ng-container matColumnDef="name"> <mat-header-cell mat-header-cell *matHeaderCellDef> Name </mat-header-cell> <mat-cell mat-cell *matCellDef="let element"> {{element.name}} </mat-cell> </ng-container> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <mat-row matRipple *matRowDef="let row; columns: displayedColumns;"></mat-row> </mat-table>
{ "end_byte": 444, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-with-ripples/table-with-ripples-example.html" }
components/src/components-examples/material/table/table-with-ripples/table-with-ripples-example.ts_0_708
import {Component} from '@angular/core'; import {MatRippleModule} from '@angular/material/core'; import {MatTableModule} from '@angular/material/table'; const ELEMENT_DATA = [ {name: 'Hydrogen'}, {name: 'Helium'}, {name: 'Lithium'}, {name: 'Beryllium'}, {name: 'Boron'}, {name: 'Carbon'}, {name: 'Nitrogen'}, {name: 'Oxygen'}, {name: 'Fluorine'}, {name: 'Neon'}, ]; /** * @title Tables with Material Design ripples. */ @Component({ selector: 'table-with-ripples-example', templateUrl: 'table-with-ripples-example.html', imports: [MatTableModule, MatRippleModule], }) export class TableWithRipplesExample { displayedColumns: string[] = ['name']; dataSource = ELEMENT_DATA; }
{ "end_byte": 708, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-with-ripples/table-with-ripples-example.ts" }
components/src/components-examples/material/table/table-footer-row/table-footer-row-example.html_0_836
<table mat-table [dataSource]="transactions" class="mat-elevation-z8"> <!-- Item Column --> <ng-container matColumnDef="item"> <th mat-header-cell *matHeaderCellDef> Item </th> <td mat-cell *matCellDef="let transaction"> {{transaction.item}} </td> <td mat-footer-cell *matFooterCellDef> Total </td> </ng-container> <!-- Cost Column --> <ng-container matColumnDef="cost"> <th mat-header-cell *matHeaderCellDef> Cost </th> <td mat-cell *matCellDef="let transaction"> {{transaction.cost | currency}} </td> <td mat-footer-cell *matFooterCellDef> {{getTotalCost() | currency}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-footer-row *matFooterRowDef="displayedColumns"></tr> </table>
{ "end_byte": 836, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-footer-row/table-footer-row-example.html" }
components/src/components-examples/material/table/table-footer-row/table-footer-row-example.ts_0_914
import {Component} from '@angular/core'; import {CurrencyPipe} from '@angular/common'; import {MatTableModule} from '@angular/material/table'; interface Transaction { item: string; cost: number; } /** * @title Footer row table */ @Component({ selector: 'table-footer-row-example', styleUrl: 'table-footer-row-example.css', templateUrl: 'table-footer-row-example.html', imports: [MatTableModule, CurrencyPipe], }) export class TableFooterRowExample { displayedColumns: string[] = ['item', 'cost']; transactions: Transaction[] = [ {item: 'Beach ball', cost: 4}, {item: 'Towel', cost: 5}, {item: 'Frisbee', cost: 2}, {item: 'Sunscreen', cost: 4}, {item: 'Cooler', cost: 25}, {item: 'Swim suit', cost: 15}, ]; /** Gets the total cost of all transactions. */ getTotalCost() { return this.transactions.map(t => t.cost).reduce((acc, value) => acc + value, 0); } }
{ "end_byte": 914, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-footer-row/table-footer-row-example.ts" }
components/src/components-examples/material/table/table-footer-row/table-footer-row-example.css_0_76
table { width: 100%; } tr.mat-mdc-footer-row td { font-weight: bold; }
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-footer-row/table-footer-row-example.css" }
components/src/components-examples/material/table/table-generated-columns/table-generated-columns-example.html_0_508
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8 demo-table"> @for (column of columns; track column) { <ng-container [matColumnDef]="column.columnDef"> <th mat-header-cell *matHeaderCellDef> {{column.header}} </th> <td mat-cell *matCellDef="let row"> {{column.cell(row)}} </td> </ng-container> } <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 508, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-generated-columns/table-generated-columns-example.html" }
components/src/components-examples/material/table/table-generated-columns/table-generated-columns-example.ts_0_1851
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Table with columns defined using a for loop instead of statically written in the template. */ @Component({ selector: 'table-generated-columns-example', styleUrl: 'table-generated-columns-example.css', templateUrl: 'table-generated-columns-example.html', imports: [MatTableModule], }) export class TableGeneratedColumnsExample { columns = [ { columnDef: 'position', header: 'No.', cell: (element: PeriodicElement) => `${element.position}`, }, { columnDef: 'name', header: 'Name', cell: (element: PeriodicElement) => `${element.name}`, }, { columnDef: 'weight', header: 'Weight', cell: (element: PeriodicElement) => `${element.weight}`, }, { columnDef: 'symbol', header: 'Symbol', cell: (element: PeriodicElement) => `${element.symbol}`, }, ]; dataSource = ELEMENT_DATA; displayedColumns = this.columns.map(c => c.columnDef); }
{ "end_byte": 1851, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-generated-columns/table-generated-columns-example.ts" }
components/src/components-examples/material/table/table-generated-columns/table-generated-columns-example.css_0_31
.demo-table { width: 100%; }
{ "end_byte": 31, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-generated-columns/table-generated-columns-example.css" }
components/src/components-examples/material/table/table-dynamic-array-data/table-dynamic-array-data-example.html_0_1326
<div class="demo-button-container"> <button mat-raised-button (click)="addData()" class="demo-button"> Add data </button> <button mat-raised-button [disabled]="!dataSource.length" (click)="removeData()" class="demo-button"> Remove data </button> </div> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8 demo-table"> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef>No.</th> <td mat-cell *matCellDef="let element">{{element.position}}</td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef>Name</th> <td mat-cell *matCellDef="let element">{{element.name}}</td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef>Weight</th> <td mat-cell *matCellDef="let element">{{element.weight}}</td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef>Symbol</th> <td mat-cell *matCellDef="let element">{{element.symbol}}</td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 1326, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-dynamic-array-data/table-dynamic-array-data-example.html" }
components/src/components-examples/material/table/table-dynamic-array-data/table-dynamic-array-data-example.ts_0_1745
import {Component, ViewChild} from '@angular/core'; import {MatTable, MatTableModule} from '@angular/material/table'; import {MatButtonModule} from '@angular/material/button'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Adding and removing data when using an array-based datasource. */ @Component({ selector: 'table-dynamic-array-data-example', styleUrl: 'table-dynamic-array-data-example.css', templateUrl: 'table-dynamic-array-data-example.html', imports: [MatButtonModule, MatTableModule], }) export class TableDynamicArrayDataExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = [...ELEMENT_DATA]; @ViewChild(MatTable) table: MatTable<PeriodicElement>; addData() { const randomElementIndex = Math.floor(Math.random() * ELEMENT_DATA.length); this.dataSource.push(ELEMENT_DATA[randomElementIndex]); this.table.renderRows(); } removeData() { this.dataSource.pop(); this.table.renderRows(); } }
{ "end_byte": 1745, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-dynamic-array-data/table-dynamic-array-data-example.ts" }
components/src/components-examples/material/table/table-dynamic-array-data/table-dynamic-array-data-example.css_0_136
.demo-table { width: 100%; } .demo-button-container { padding-bottom: 16px; } .demo-button + .demo-button { margin-left: 8px; }
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-dynamic-array-data/table-dynamic-array-data-example.css" }
components/src/components-examples/material/table/table-multiple-header-footer/table-multiple-header-footer-example.ts_0_987
import {Component} from '@angular/core'; import {CurrencyPipe} from '@angular/common'; import {MatTableModule} from '@angular/material/table'; interface Transaction { item: string; cost: number; } /** * @title Table with multiple header and footer rows */ @Component({ selector: 'table-multiple-header-footer-example', styleUrl: 'table-multiple-header-footer-example.css', templateUrl: 'table-multiple-header-footer-example.html', imports: [MatTableModule, CurrencyPipe], }) export class TableMultipleHeaderFooterExample { displayedColumns: string[] = ['item', 'cost']; transactions: Transaction[] = [ {item: 'Beach ball', cost: 4}, {item: 'Towel', cost: 5}, {item: 'Frisbee', cost: 2}, {item: 'Sunscreen', cost: 4}, {item: 'Cooler', cost: 25}, {item: 'Swim suit', cost: 15}, ]; /** Gets the total cost of all transactions. */ getTotalCost() { return this.transactions.map(t => t.cost).reduce((acc, value) => acc + value, 0); } }
{ "end_byte": 987, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-multiple-header-footer/table-multiple-header-footer-example.ts" }
components/src/components-examples/material/table/table-multiple-header-footer/table-multiple-header-footer-example.css_0_245
table { width: 100%; } .example-first-header-row th { border-bottom: none; } .example-second-header-row { font-style: italic; } .example-first-footer-row { font-weight: bold; } .example-second-footer-row td { font-style: italic; }
{ "end_byte": 245, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-multiple-header-footer/table-multiple-header-footer-example.css" }
components/src/components-examples/material/table/table-multiple-header-footer/table-multiple-header-footer-example.html_0_1837
<table mat-table [dataSource]="transactions" class="mat-elevation-z8"> <!-- Item Column --> <ng-container matColumnDef="item"> <th mat-header-cell *matHeaderCellDef> Item </th> <td mat-cell *matCellDef="let transaction"> {{transaction.item}} </td> <td mat-footer-cell *matFooterCellDef> Total </td> </ng-container> <!-- Cost Column --> <ng-container matColumnDef="cost"> <th mat-header-cell *matHeaderCellDef> Cost </th> <td mat-cell *matCellDef="let transaction"> {{transaction.cost | currency}} </td> <td mat-footer-cell *matFooterCellDef> {{getTotalCost() | currency}} </td> </ng-container> <!-- Item Description Column --> <ng-container matColumnDef="item-description"> <th mat-header-cell *matHeaderCellDef> Name of the item purchased </th> </ng-container> <!-- Cost Description Column --> <ng-container matColumnDef="cost-description"> <th mat-header-cell *matHeaderCellDef> Cost of the item in USD </th> </ng-container> <!-- Disclaimer column --> <ng-container matColumnDef="disclaimer"> <td mat-footer-cell *matFooterCellDef colspan="2"> Please note that the cost of items displayed are completely and totally made up. </td> </ng-container> <!-- The table will render two header rows, one data row per data object, and two footer rows. --> <tr mat-header-row *matHeaderRowDef="displayedColumns" class="example-first-header-row"> </tr> <tr mat-header-row *matHeaderRowDef="['item-description', 'cost-description']" class="example-second-header-row"> </tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-footer-row *matFooterRowDef="displayedColumns" class="example-first-footer-row"></tr> <tr mat-footer-row *matFooterRowDef="['disclaimer']" class="example-second-footer-row"></tr> </table>
{ "end_byte": 1837, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-multiple-header-footer/table-multiple-header-footer-example.html" }
components/src/components-examples/material/table/table-row-binding/table-row-binding-example.ts_0_1331
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Binding event handlers and properties to the table rows. */ @Component({ selector: 'table-row-binding-example', styleUrl: 'table-row-binding-example.css', templateUrl: 'table-row-binding-example.html', imports: [MatTableModule], }) export class TableRowBindingExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA; clickedRows = new Set<PeriodicElement>(); }
{ "end_byte": 1331, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-row-binding/table-row-binding-example.ts" }
components/src/components-examples/material/table/table-row-binding/table-row-binding-example.html_0_1374
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8 demo-table"> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef>No.</th> <td mat-cell *matCellDef="let element">{{element.position}}</td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef>Name</th> <td mat-cell *matCellDef="let element">{{element.name}}</td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef>Weight</th> <td mat-cell *matCellDef="let element">{{element.weight}}</td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef>Symbol</th> <td mat-cell *matCellDef="let element">{{element.symbol}}</td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row (click)="clickedRows.add(row)" [class.demo-row-is-clicked]="clickedRows.has(row)" *matRowDef="let row; columns: displayedColumns;" ></tr> </table> <div> <h3> Click Log </h3> </div> @if (!clickedRows.size) { <div>Clicked rows will be logged here</div> } <ul> @for (clickedRow of clickedRows; track clickedRow) { <li>Clicked on {{clickedRow.name}}</li> } </ul>
{ "end_byte": 1374, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-row-binding/table-row-binding-example.html" }
components/src/components-examples/material/table/table-row-binding/table-row-binding-example.css_0_274
.demo-table { width: 100%; } .mat-mdc-row .mat-mdc-cell { border-bottom: 1px solid transparent; border-top: 1px solid transparent; cursor: pointer; } .mat-mdc-row:hover .mat-mdc-cell { border-color: currentColor; } .demo-row-is-clicked { font-weight: bold; }
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-row-binding/table-row-binding-example.css" }
components/src/components-examples/material/table/table-http/table-http-example.ts_0_3210
import {HttpClient} from '@angular/common/http'; import {Component, ViewChild, AfterViewInit, inject} from '@angular/core'; import {MatPaginator, MatPaginatorModule} from '@angular/material/paginator'; import {MatSort, MatSortModule, SortDirection} from '@angular/material/sort'; import {merge, Observable, of as observableOf} from 'rxjs'; import {catchError, map, startWith, switchMap} from 'rxjs/operators'; import {MatTableModule} from '@angular/material/table'; import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; import {DatePipe} from '@angular/common'; /** * @title Table retrieving data through HTTP */ @Component({ selector: 'table-http-example', styleUrl: 'table-http-example.css', templateUrl: 'table-http-example.html', imports: [MatProgressSpinnerModule, MatTableModule, MatSortModule, MatPaginatorModule, DatePipe], }) export class TableHttpExample implements AfterViewInit { private _httpClient = inject(HttpClient); displayedColumns: string[] = ['created', 'state', 'number', 'title']; exampleDatabase: ExampleHttpDatabase | null; data: GithubIssue[] = []; resultsLength = 0; isLoadingResults = true; isRateLimitReached = false; @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; ngAfterViewInit() { this.exampleDatabase = new ExampleHttpDatabase(this._httpClient); // If the user changes the sort order, reset back to the first page. this.sort.sortChange.subscribe(() => (this.paginator.pageIndex = 0)); merge(this.sort.sortChange, this.paginator.page) .pipe( startWith({}), switchMap(() => { this.isLoadingResults = true; return this.exampleDatabase!.getRepoIssues( this.sort.active, this.sort.direction, this.paginator.pageIndex, ).pipe(catchError(() => observableOf(null))); }), map(data => { // Flip flag to show that loading has finished. this.isLoadingResults = false; this.isRateLimitReached = data === null; if (data === null) { return []; } // Only refresh the result length if there is new data. In case of rate // limit errors, we do not want to reset the paginator to zero, as that // would prevent users from re-triggering requests. this.resultsLength = data.total_count; return data.items; }), ) .subscribe(data => (this.data = data)); } } export interface GithubApi { items: GithubIssue[]; total_count: number; } export interface GithubIssue { created_at: string; number: string; state: string; title: string; } /** An example database that the data source uses to retrieve data for the table. */ export class ExampleHttpDatabase { constructor(private _httpClient: HttpClient) {} getRepoIssues(sort: string, order: SortDirection, page: number): Observable<GithubApi> { const href = 'https://api.github.com/search/issues'; const requestUrl = `${href}?q=repo:angular/components&sort=${sort}&order=${order}&page=${ page + 1 }`; return this._httpClient.get<GithubApi>(requestUrl); } }
{ "end_byte": 3210, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-http/table-http-example.ts" }
components/src/components-examples/material/table/table-http/table-http-example.css_0_608
/* Structure */ .example-container { position: relative; } .example-table-container { position: relative; min-height: 200px; max-height: 400px; overflow: auto; } table { width: 100%; } .example-loading-shade { position: absolute; top: 0; left: 0; bottom: 56px; right: 0; background: rgba(0, 0, 0, 0.15); z-index: 1; display: flex; align-items: center; justify-content: center; } .example-rate-limit-reached { max-width: 360px; text-align: center; } /* Column Widths */ .mat-column-number, .mat-column-state { width: 64px; } .mat-column-created { width: 124px; }
{ "end_byte": 608, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-http/table-http-example.css" }
components/src/components-examples/material/table/table-http/table-http-example.html_0_1819
<div class="example-container mat-elevation-z8"> @if (isLoadingResults || isRateLimitReached) { <div class="example-loading-shade"> @if (isLoadingResults) { <mat-spinner></mat-spinner> } @if (isRateLimitReached) { <div class="example-rate-limit-reached"> GitHub's API rate limit has been reached. It will be reset in one minute. </div> } </div> } <div class="example-table-container"> <table mat-table [dataSource]="data" class="example-table" matSort matSortActive="created" matSortDisableClear matSortDirection="desc"> <!-- Number Column --> <ng-container matColumnDef="number"> <th mat-header-cell *matHeaderCellDef>#</th> <td mat-cell *matCellDef="let row">{{row.number}}</td> </ng-container> <!-- Title Column --> <ng-container matColumnDef="title"> <th mat-header-cell *matHeaderCellDef>Title</th> <td mat-cell *matCellDef="let row">{{row.title}}</td> </ng-container> <!-- State Column --> <ng-container matColumnDef="state"> <th mat-header-cell *matHeaderCellDef>State</th> <td mat-cell *matCellDef="let row">{{row.state}}</td> </ng-container> <!-- Created Column --> <ng-container matColumnDef="created"> <th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Created </th> <td mat-cell *matCellDef="let row">{{row.created_at | date}}</td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table> </div> <mat-paginator [length]="resultsLength" [pageSize]="30" aria-label="Select page of GitHub search results"></mat-paginator> </div>
{ "end_byte": 1819, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-http/table-http-example.html" }
components/src/components-examples/material/table/table-selection/table-selection-example.html_0_1814
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <!-- Checkbox Column --> <ng-container matColumnDef="select"> <th mat-header-cell *matHeaderCellDef> <mat-checkbox (change)="$event ? toggleAllRows() : null" [checked]="selection.hasValue() && isAllSelected()" [indeterminate]="selection.hasValue() && !isAllSelected()" [aria-label]="checkboxLabel()"> </mat-checkbox> </th> <td mat-cell *matCellDef="let row"> <mat-checkbox (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(row) : null" [checked]="selection.isSelected(row)" [aria-label]="checkboxLabel(row)"> </mat-checkbox> </td> </ng-container> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="selection.toggle(row)"> </tr> </table>
{ "end_byte": 1814, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-selection/table-selection-example.html" }
components/src/components-examples/material/table/table-selection/table-selection-example.css_0_25
table { width: 100%; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-selection/table-selection-example.css" }
components/src/components-examples/material/table/table-selection/table-selection-example.ts_0_2300
import {SelectionModel} from '@angular/cdk/collections'; import {Component} from '@angular/core'; import {MatTableDataSource, MatTableModule} from '@angular/material/table'; import {MatCheckboxModule} from '@angular/material/checkbox'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Table with selection */ @Component({ selector: 'table-selection-example', styleUrl: 'table-selection-example.css', templateUrl: 'table-selection-example.html', imports: [MatTableModule, MatCheckboxModule], }) export class TableSelectionExample { displayedColumns: string[] = ['select', 'position', 'name', 'weight', 'symbol']; dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA); selection = new SelectionModel<PeriodicElement>(true, []); /** Whether the number of selected elements matches the total number of rows. */ isAllSelected() { const numSelected = this.selection.selected.length; const numRows = this.dataSource.data.length; return numSelected === numRows; } /** Selects all rows if they are not all selected; otherwise clear selection. */ toggleAllRows() { if (this.isAllSelected()) { this.selection.clear(); return; } this.selection.select(...this.dataSource.data); } /** The label for the checkbox on the passed row */ checkboxLabel(row?: PeriodicElement): string { if (!row) { return `${this.isAllSelected() ? 'deselect' : 'select'} all`; } return `${this.selection.isSelected(row) ? 'deselect' : 'select'} row ${row.position + 1}`; } }
{ "end_byte": 2300, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-selection/table-selection-example.ts" }
components/src/components-examples/material/table/table-wrapped/table-wrapped-example.html_0_924
<div> <button mat-raised-button (click)="clearTable()">Clear table</button> <button mat-raised-button (click)="addData()">Add data</button> </div> <wrapper-table [dataSource]="dataSource" [columns]="displayedColumns" matSort #sort="matSort"> <!-- Custom column definition to be provided to the wrapper table. --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Custom row definitions to be provided to the wrapper table. --> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <!-- Row shown when there is no matching data that will be provided to the wrapper table. --> <tr class="mat-row" *matNoDataRow> <td class="mat-cell" colspan="4">No data</td> </tr> </wrapper-table>
{ "end_byte": 924, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-wrapped/table-wrapped-example.html" }
components/src/components-examples/material/table/table-wrapped/table-wrapped-example.css_0_60
table { width: 100%; } button { margin: 0 8px 8px 0; }
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-wrapped/table-wrapped-example.css" }
components/src/components-examples/material/table/table-wrapped/table-wrapped-example.ts_0_3155
import {DataSource} from '@angular/cdk/collections'; import { AfterContentInit, Component, ContentChildren, AfterViewInit, QueryList, ViewChild, ContentChild, forwardRef, input, } from '@angular/core'; import {MatSort, MatSortModule} from '@angular/material/sort'; import { MatColumnDef, MatHeaderRowDef, MatNoDataRow, MatRowDef, MatTable, MatTableDataSource, MatTableModule, } from '@angular/material/table'; import {MatButtonModule} from '@angular/material/button'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Table example that shows how to wrap a table component for definition and behavior reuse. */ @Component({ selector: 'table-wrapped-example', styleUrl: 'table-wrapped-example.css', templateUrl: 'table-wrapped-example.html', imports: [MatButtonModule, forwardRef(() => WrapperTable), MatSortModule, MatTableModule], }) export class TableWrappedExample implements AfterViewInit { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA); @ViewChild('sort') sort: MatSort; ngAfterViewInit() { this.dataSource.sort = this.sort; } clearTable() { this.dataSource.data = []; } addData() { this.dataSource.data = ELEMENT_DATA; } } /** * Table component that accepts column and row definitions in its content to be registered to the * table. */ @Component({ selector: 'wrapper-table', templateUrl: 'wrapper-table.html', styles: ` table { width: 100%; } `, imports: [MatTableModule, MatSortModule], }) export class WrapperTable<T> implements AfterContentInit { @ContentChildren(MatHeaderRowDef) headerRowDefs: QueryList<MatHeaderRowDef>; @ContentChildren(MatRowDef) rowDefs: QueryList<MatRowDef<T>>; @ContentChildren(MatColumnDef) columnDefs: QueryList<MatColumnDef>; @ContentChild(MatNoDataRow) noDataRow: MatNoDataRow; @ViewChild(MatTable, {static: true}) table: MatTable<T>; readonly columns = input.required<string[]>(); readonly dataSource = input.required<DataSource<T>>(); ngAfterContentInit() { this.columnDefs.forEach(columnDef => this.table.addColumnDef(columnDef)); this.rowDefs.forEach(rowDef => this.table.addRowDef(rowDef)); this.headerRowDefs.forEach(headerRowDef => this.table.addHeaderRowDef(headerRowDef)); this.table.setNoDataRow(this.noDataRow); } }
{ "end_byte": 3155, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-wrapped/table-wrapped-example.ts" }
components/src/components-examples/material/table/table-wrapped/wrapper-table.html_0_766
<table mat-table [dataSource]="dataSource()" class="mat-elevation-z8"> <ng-content></ng-content> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef mat-sort-header> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef mat-sort-header> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Color Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> </table>
{ "end_byte": 766, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-wrapped/wrapper-table.html" }
components/src/components-examples/material/table/table-sorting/table-sorting-example.ts_0_2170
import {LiveAnnouncer} from '@angular/cdk/a11y'; import {AfterViewInit, Component, ViewChild, inject} from '@angular/core'; import {MatSort, Sort, MatSortModule} from '@angular/material/sort'; import {MatTableDataSource, MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Table with sorting */ @Component({ selector: 'table-sorting-example', styleUrl: 'table-sorting-example.css', templateUrl: 'table-sorting-example.html', imports: [MatTableModule, MatSortModule], }) export class TableSortingExample implements AfterViewInit { private _liveAnnouncer = inject(LiveAnnouncer); displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = new MatTableDataSource(ELEMENT_DATA); @ViewChild(MatSort) sort: MatSort; ngAfterViewInit() { this.dataSource.sort = this.sort; } /** Announce the change in sort state for assistive technology. */ announceSortChange(sortState: Sort) { // This example uses English messages. If your application supports // multiple language, you would internationalize these strings. // Furthermore, you can customize the message to add additional // details about the values being sorted. if (sortState.direction) { this._liveAnnouncer.announce(`Sorted ${sortState.direction}ending`); } else { this._liveAnnouncer.announce('Sorting cleared'); } } }
{ "end_byte": 2170, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sorting/table-sorting-example.ts" }
components/src/components-examples/material/table/table-sorting/table-sorting-example.html_0_1356
<table mat-table [dataSource]="dataSource" matSort (matSortChange)="announceSortChange($event)" class="mat-elevation-z8"> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by number"> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by name"> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by weight"> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by symbol"> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 1356, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sorting/table-sorting-example.html" }
components/src/components-examples/material/table/table-sorting/table-sorting-example.css_0_72
table { width: 100%; } th.mat-sort-header-sorted { color: black; }
{ "end_byte": 72, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sorting/table-sorting-example.css" }
components/src/components-examples/material/table/table-column-styling/table-column-styling-example.html_0_1069
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8 demo-table"> <!-- Position Column --> <ng-container matColumnDef="demo-position"> <th mat-header-cell *matHeaderCellDef> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="demo-name"> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="demo-weight"> <th mat-header-cell *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="demo-symbol"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 1069, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-column-styling/table-column-styling-example.html" }
components/src/components-examples/material/table/table-column-styling/table-column-styling-example.css_0_368
.demo-table { width: 100%; } .mat-column-demo-position { width: 32px; border-right: 1px solid currentColor; padding-right: 24px; text-align: center; } .mat-column-demo-name { padding-left: 16px; font-size: 20px; } .mat-column-demo-weight { font-style: italic; } .mat-column-demo-symbol { width: 32px; text-align: center; font-weight: bold; }
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-column-styling/table-column-styling-example.css" }
components/src/components-examples/material/table/table-column-styling/table-column-styling-example.ts_0_1318
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Styling columns using their auto-generated column names */ @Component({ selector: 'table-column-styling-example', styleUrl: 'table-column-styling-example.css', templateUrl: 'table-column-styling-example.html', imports: [MatTableModule], }) export class TableColumnStylingExample { displayedColumns: string[] = ['demo-position', 'demo-name', 'demo-weight', 'demo-symbol']; dataSource = ELEMENT_DATA; }
{ "end_byte": 1318, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-column-styling/table-column-styling-example.ts" }
components/src/components-examples/material/table/table-harness/table-harness-example.ts_0_1061
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; /** * @title Testing with MatTableHarness */ @Component({ selector: 'table-harness-example', templateUrl: 'table-harness-example.html', imports: [MatTableModule], }) export class TableHarnessExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; }
{ "end_byte": 1061, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-harness/table-harness-example.ts" }
components/src/components-examples/material/table/table-harness/table-harness-example.spec.ts_0_3426
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed'; import {MatTableHarness} from '@angular/material/table/testing'; import {HarnessLoader, parallel} from '@angular/cdk/testing'; import {TableHarnessExample} from './table-harness-example'; describe('TableHarnessExample', () => { let fixture: ComponentFixture<TableHarnessExample>; let loader: HarnessLoader; beforeEach(() => { fixture = TestBed.createComponent(TableHarnessExample); fixture.detectChanges(); loader = TestbedHarnessEnvironment.loader(fixture); }); it('should load harness for a table', async () => { const tables = await loader.getAllHarnesses(MatTableHarness); expect(tables.length).toBe(1); }); it('should get the different kinds of rows in the table', async () => { const table = await loader.getHarness(MatTableHarness); const headerRows = await table.getHeaderRows(); const footerRows = await table.getFooterRows(); const rows = await table.getRows(); expect(headerRows.length).toBe(1); expect(footerRows.length).toBe(1); expect(rows.length).toBe(10); }); it('should get cells inside a row', async () => { const table = await loader.getHarness(MatTableHarness); const headerRows = await table.getHeaderRows(); const footerRows = await table.getFooterRows(); const rows = await table.getRows(); const headerCells = (await parallel(() => headerRows.map(row => row.getCells()))).map( row => row.length, ); const footerCells = (await parallel(() => footerRows.map(row => row.getCells()))).map( row => row.length, ); const cells = (await parallel(() => rows.map(row => row.getCells()))).map(row => row.length); expect(headerCells).toEqual([4]); expect(cells).toEqual([4, 4, 4, 4, 4, 4, 4, 4, 4, 4]); expect(footerCells).toEqual([4]); }); it('should be able to get the text of a cell', async () => { const table = await loader.getHarness(MatTableHarness); const secondRow = (await table.getRows())[1]; const cells = await secondRow.getCells(); const cellTexts = await parallel(() => cells.map(cell => cell.getText())); expect(cellTexts).toEqual(['2', 'Helium', '4.0026', 'He']); }); it('should be able to get the column name of a cell', async () => { const table = await loader.getHarness(MatTableHarness); const fifthRow = (await table.getRows())[1]; const cells = await fifthRow.getCells(); const cellColumnNames = await parallel(() => cells.map(cell => cell.getColumnName())); expect(cellColumnNames).toEqual(['position', 'name', 'weight', 'symbol']); }); it('should be able to filter cells by text', async () => { const table = await loader.getHarness(MatTableHarness); const firstRow = (await table.getRows())[0]; const cells = await firstRow.getCells({text: '1.0079'}); const cellTexts = await parallel(() => cells.map(cell => cell.getText())); expect(cellTexts).toEqual(['1.0079']); }); it('should be able to filter cells by column name', async () => { const table = await loader.getHarness(MatTableHarness); const firstRow = (await table.getRows())[0]; const cells = await firstRow.getCells({columnName: 'symbol'}); const cellTexts = await parallel(() => cells.map(cell => cell.getText())); expect(cellTexts).toEqual(['H']); }); });
{ "end_byte": 3426, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-harness/table-harness-example.spec.ts" }
components/src/components-examples/material/table/table-harness/table-harness-example.html_0_1233
<table mat-table [dataSource]="dataSource"> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef>No.</th> <td mat-cell *matCellDef="let element">{{element.position}}</td> <td mat-footer-cell *matFooterCellDef>Number of the element</td> </ng-container> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef>Name</th> <td mat-cell *matCellDef="let element">{{element.name}}</td> <td mat-footer-cell *matFooterCellDef>Name of the element</td> </ng-container> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef>Weight</th> <td mat-cell *matCellDef="let element">{{element.weight}}</td> <td mat-footer-cell *matFooterCellDef>Weight of the element</td> </ng-container> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef>Symbol</th> <td mat-cell *matCellDef="let element">{{element.symbol}}</td> <td mat-footer-cell *matFooterCellDef>Symbol of the element</td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-footer-row *matFooterRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 1233, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-harness/table-harness-example.html" }
components/src/components-examples/material/table/table-sticky-complex/table-sticky-complex-example.css_0_698
.example-container { height: 400px; overflow: auto; } .mat-mdc-table-sticky { background: #59abfd; opacity: 1; } .example-sticky-toggle-group { margin: 8px; } .mat-column-filler { padding: 0 8px; font-size: 10px; text-align: center; } .mat-mdc-header-cell, .mat-mdc-footer-cell, .mat-mdc-cell { min-width: 80px; box-sizing: border-box; } .mat-mdc-table-sticky-border-elem-top { border-bottom: 2px solid midnightblue; } .mat-mdc-table-sticky-border-elem-right { border-left: 2px solid midnightblue; } .mat-mdc-table-sticky-border-elem-bottom { border-top: 2px solid midnightblue; } .mat-mdc-table-sticky-border-elem-left { border-right: 2px solid midnightblue; }
{ "end_byte": 698, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-complex/table-sticky-complex-example.css" }
components/src/components-examples/material/table/table-sticky-complex/table-sticky-complex-example.ts_0_2050
import {Component} from '@angular/core'; import {MatButtonToggleGroup, MatButtonToggleModule} from '@angular/material/button-toggle'; import {MatTableModule} from '@angular/material/table'; import {MatButtonModule} from '@angular/material/button'; /** * @title Tables with toggle-able sticky headers, footers, and columns */ @Component({ selector: 'table-sticky-complex-example', styleUrl: 'table-sticky-complex-example.css', templateUrl: 'table-sticky-complex-example.html', imports: [MatButtonModule, MatButtonToggleModule, MatTableModule], }) export class TableStickyComplexExample { displayedColumns: string[] = []; dataSource = ELEMENT_DATA; tables = [0]; constructor() { this.displayedColumns.length = 24; this.displayedColumns.fill('filler'); // The first two columns should be position and name; the last two columns: weight, symbol this.displayedColumns[0] = 'position'; this.displayedColumns[1] = 'name'; this.displayedColumns[22] = 'weight'; this.displayedColumns[23] = 'symbol'; } /** Whether the button toggle group contains the id as an active value. */ isSticky(buttonToggleGroup: MatButtonToggleGroup, id: string) { return (buttonToggleGroup.value || []).indexOf(id) !== -1; } } export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ];
{ "end_byte": 2050, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-complex/table-sticky-complex-example.ts" }
components/src/components-examples/material/table/table-sticky-complex/table-sticky-complex-example.html_0_3704
<div> <button mat-raised-button (click)="tables.push(tables.length)">Add table</button> <button mat-raised-button (click)="tables.pop()">Remove table</button> </div> <div> Sticky Headers: <mat-button-toggle-group multiple [value]="['header-1']" #stickyHeaders="matButtonToggleGroup" class="example-sticky-toggle-group"> <mat-button-toggle value="header-1"> Row 1 </mat-button-toggle> <mat-button-toggle value="header-2"> Row 2 </mat-button-toggle> </mat-button-toggle-group> </div> <div> Sticky Footers: <mat-button-toggle-group multiple [value]="['footer-1']" #stickyFooters="matButtonToggleGroup" class="example-sticky-toggle-group"> <mat-button-toggle value="footer-1"> Row 1 </mat-button-toggle> <mat-button-toggle value="footer-2"> Row 2 </mat-button-toggle> </mat-button-toggle-group> </div> <div> Sticky Columns: <mat-button-toggle-group multiple [value]="['position', 'symbol']" #stickyColumns="matButtonToggleGroup" class="example-sticky-toggle-group"> <mat-button-toggle value="position"> Position </mat-button-toggle> <mat-button-toggle value="name"> Name </mat-button-toggle> <mat-button-toggle value="weight"> Weight </mat-button-toggle> <mat-button-toggle value="symbol"> Symbol </mat-button-toggle> </mat-button-toggle-group> </div> <section class="example-container mat-elevation-z8" tabindex="0"> @for (table of tables; track table) { <table mat-table [dataSource]="dataSource"> <ng-container matColumnDef="position" [sticky]="isSticky(stickyColumns, 'position')"> <th mat-header-cell *matHeaderCellDef> Position </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> <td mat-footer-cell *matFooterCellDef> Position Footer </td> </ng-container> <ng-container matColumnDef="name" [sticky]="isSticky(stickyColumns, 'name')"> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> <td mat-footer-cell *matFooterCellDef> Name Footer </td> </ng-container> <ng-container matColumnDef="weight" [stickyEnd]="isSticky(stickyColumns, 'weight')"> <th mat-header-cell *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> <td mat-footer-cell *matFooterCellDef> Weight Footer </td> </ng-container> <ng-container matColumnDef="symbol" [stickyEnd]="isSticky(stickyColumns, 'symbol')"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> <td mat-footer-cell *matFooterCellDef> Symbol Footer </td> </ng-container> <ng-container matColumnDef="filler"> <th mat-header-cell *matHeaderCellDef> Filler header cell </th> <td mat-cell *matCellDef="let element"> Filler data cell </td> <td mat-footer-cell *matFooterCellDef> Filler footer cell </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: isSticky(stickyHeaders, 'header-1')"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: isSticky(stickyHeaders, 'header-2')"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-footer-row *matFooterRowDef="displayedColumns; sticky: isSticky(stickyFooters, 'footer-1')"></tr> <tr mat-footer-row *matFooterRowDef="displayedColumns; sticky: isSticky(stickyFooters, 'footer-2')"></tr> </table> } </section>
{ "end_byte": 3704, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-complex/table-sticky-complex-example.html" }
components/src/components-examples/material/table/table-dynamic-observable-data/table-dynamic-observable-data-example.css_0_136
.demo-table { width: 100%; } .demo-button-container { padding-bottom: 16px; } .demo-button + .demo-button { margin-left: 8px; }
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-dynamic-observable-data/table-dynamic-observable-data-example.css" }
components/src/components-examples/material/table/table-dynamic-observable-data/table-dynamic-observable-data-example.ts_0_2348
import {Component} from '@angular/core'; import {DataSource} from '@angular/cdk/collections'; import {Observable, ReplaySubject} from 'rxjs'; import {MatTableModule} from '@angular/material/table'; import {MatButtonModule} from '@angular/material/button'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Adding and removing data when using an observable-based datasource. */ @Component({ selector: 'table-dynamic-observable-data-example', styleUrl: 'table-dynamic-observable-data-example.css', templateUrl: 'table-dynamic-observable-data-example.html', imports: [MatButtonModule, MatTableModule], }) export class TableDynamicObservableDataExample { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataToDisplay = [...ELEMENT_DATA]; dataSource = new ExampleDataSource(this.dataToDisplay); addData() { const randomElementIndex = Math.floor(Math.random() * ELEMENT_DATA.length); this.dataToDisplay = [...this.dataToDisplay, ELEMENT_DATA[randomElementIndex]]; this.dataSource.setData(this.dataToDisplay); } removeData() { this.dataToDisplay = this.dataToDisplay.slice(0, -1); this.dataSource.setData(this.dataToDisplay); } } class ExampleDataSource extends DataSource<PeriodicElement> { private _dataStream = new ReplaySubject<PeriodicElement[]>(); constructor(initialData: PeriodicElement[]) { super(); this.setData(initialData); } connect(): Observable<PeriodicElement[]> { return this._dataStream; } disconnect() {} setData(data: PeriodicElement[]) { this._dataStream.next(data); } }
{ "end_byte": 2348, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-dynamic-observable-data/table-dynamic-observable-data-example.ts" }
components/src/components-examples/material/table/table-dynamic-observable-data/table-dynamic-observable-data-example.html_0_1329
<div class="demo-button-container"> <button mat-raised-button (click)="addData()" class="demo-button"> Add data </button> <button mat-raised-button [disabled]="!dataToDisplay.length" (click)="removeData()" class="demo-button"> Remove data </button> </div> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8 demo-table"> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef>No.</th> <td mat-cell *matCellDef="let element">{{element.position}}</td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef>Name</th> <td mat-cell *matCellDef="let element">{{element.name}}</td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef>Weight</th> <td mat-cell *matCellDef="let element">{{element.weight}}</td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef>Symbol</th> <td mat-cell *matCellDef="let element">{{element.symbol}}</td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table>
{ "end_byte": 1329, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-dynamic-observable-data/table-dynamic-observable-data-example.html" }
components/src/components-examples/material/table/table-overview/table-overview-example.ts_0_2559
import {AfterViewInit, Component, ViewChild} from '@angular/core'; import {MatPaginator, MatPaginatorModule} from '@angular/material/paginator'; import {MatSort, MatSortModule} from '@angular/material/sort'; import {MatTableDataSource, MatTableModule} from '@angular/material/table'; import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; export interface UserData { id: string; name: string; progress: string; fruit: string; } /** Constants used to fill up our data base. */ const FRUITS: string[] = [ 'blueberry', 'lychee', 'kiwi', 'mango', 'peach', 'lime', 'pomegranate', 'pineapple', ]; const NAMES: string[] = [ 'Maia', 'Asher', 'Olivia', 'Atticus', 'Amelia', 'Jack', 'Charlotte', 'Theodore', 'Isla', 'Oliver', 'Isabella', 'Jasper', 'Cora', 'Levi', 'Violet', 'Arthur', 'Mia', 'Thomas', 'Elizabeth', ]; /** * @title Data table with sorting, pagination, and filtering. */ @Component({ selector: 'table-overview-example', styleUrl: 'table-overview-example.css', templateUrl: 'table-overview-example.html', imports: [MatFormFieldModule, MatInputModule, MatTableModule, MatSortModule, MatPaginatorModule], }) export class TableOverviewExample implements AfterViewInit { displayedColumns: string[] = ['id', 'name', 'progress', 'fruit']; dataSource: MatTableDataSource<UserData>; @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; constructor() { // Create 100 users const users = Array.from({length: 100}, (_, k) => createNewUser(k + 1)); // Assign the data to the data source for the table to render this.dataSource = new MatTableDataSource(users); } ngAfterViewInit() { this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort; } applyFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; this.dataSource.filter = filterValue.trim().toLowerCase(); if (this.dataSource.paginator) { this.dataSource.paginator.firstPage(); } } } /** Builds and returns a new User. */ function createNewUser(id: number): UserData { const name = NAMES[Math.round(Math.random() * (NAMES.length - 1))] + ' ' + NAMES[Math.round(Math.random() * (NAMES.length - 1))].charAt(0) + '.'; return { id: id.toString(), name: name, progress: Math.round(Math.random() * 100).toString(), fruit: FRUITS[Math.round(Math.random() * (FRUITS.length - 1))], }; }
{ "end_byte": 2559, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-overview/table-overview-example.ts" }
components/src/components-examples/material/table/table-overview/table-overview-example.html_0_1573
<mat-form-field> <mat-label>Filter</mat-label> <input matInput (keyup)="applyFilter($event)" placeholder="Ex. Mia" #input> </mat-form-field> <div class="mat-elevation-z8"> <table mat-table [dataSource]="dataSource" matSort> <!-- ID Column --> <ng-container matColumnDef="id"> <th mat-header-cell *matHeaderCellDef mat-sort-header> ID </th> <td mat-cell *matCellDef="let row"> {{row.id}} </td> </ng-container> <!-- Progress Column --> <ng-container matColumnDef="progress"> <th mat-header-cell *matHeaderCellDef mat-sort-header> Progress </th> <td mat-cell *matCellDef="let row"> {{row.progress}}% </td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th> <td mat-cell *matCellDef="let row"> {{row.name}} </td> </ng-container> <!-- Fruit Column --> <ng-container matColumnDef="fruit"> <th mat-header-cell *matHeaderCellDef mat-sort-header> Fruit </th> <td mat-cell *matCellDef="let row"> {{row.fruit}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <!-- Row shown when there is no matching data. --> <tr class="mat-row" *matNoDataRow> <td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td> </tr> </table> <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select page of users"></mat-paginator> </div>
{ "end_byte": 1573, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-overview/table-overview-example.html" }
components/src/components-examples/material/table/table-overview/table-overview-example.css_0_110
table { width: 100%; } .mat-mdc-form-field { font-size: 14px; width: 100%; } td, th { width: 25%; }
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-overview/table-overview-example.css" }
components/src/components-examples/material/table/table-pagination/table-pagination-example.ts_0_2244
import {AfterViewInit, Component, ViewChild} from '@angular/core'; import {MatPaginator, MatPaginatorModule} from '@angular/material/paginator'; import {MatTableDataSource, MatTableModule} from '@angular/material/table'; /** * @title Table with pagination */ @Component({ selector: 'table-pagination-example', styleUrl: 'table-pagination-example.css', templateUrl: 'table-pagination-example.html', imports: [MatTableModule, MatPaginatorModule], }) export class TablePaginationExample implements AfterViewInit { displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA); @ViewChild(MatPaginator) paginator: MatPaginator; ngAfterViewInit() { this.dataSource.paginator = this.paginator; } } export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, {position: 11, name: 'Sodium', weight: 22.9897, symbol: 'Na'}, {position: 12, name: 'Magnesium', weight: 24.305, symbol: 'Mg'}, {position: 13, name: 'Aluminum', weight: 26.9815, symbol: 'Al'}, {position: 14, name: 'Silicon', weight: 28.0855, symbol: 'Si'}, {position: 15, name: 'Phosphorus', weight: 30.9738, symbol: 'P'}, {position: 16, name: 'Sulfur', weight: 32.065, symbol: 'S'}, {position: 17, name: 'Chlorine', weight: 35.453, symbol: 'Cl'}, {position: 18, name: 'Argon', weight: 39.948, symbol: 'Ar'}, {position: 19, name: 'Potassium', weight: 39.0983, symbol: 'K'}, {position: 20, name: 'Calcium', weight: 40.078, symbol: 'Ca'}, ];
{ "end_byte": 2244, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-pagination/table-pagination-example.ts" }
components/src/components-examples/material/table/table-pagination/table-pagination-example.html_0_1270
<div class="mat-elevation-z8"> <table mat-table [dataSource]="dataSource"> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table> <mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons aria-label="Select page of periodic elements"> </mat-paginator> </div>
{ "end_byte": 1270, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-pagination/table-pagination-example.html" }
components/src/components-examples/material/table/table-pagination/table-pagination-example.css_0_25
table { width: 100%; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-pagination/table-pagination-example.css" }
components/src/components-examples/material/table/table-sticky-header/table-sticky-header-example.html_0_1152
<section class="example-container mat-elevation-z8" tabindex="0"> <table mat-table [dataSource]="dataSource"> <!-- Position Column --> <ng-container matColumnDef="position"> <th mat-header-cell *matHeaderCellDef> No. </th> <td mat-cell *matCellDef="let element"> {{element.position}} </td> </ng-container> <!-- Name Column --> <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDef> Name </th> <td mat-cell *matCellDef="let element"> {{element.name}} </td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="weight"> <th mat-header-cell *matHeaderCellDef> Weight </th> <td mat-cell *matCellDef="let element"> {{element.weight}} </td> </ng-container> <!-- Symbol Column --> <ng-container matColumnDef="symbol"> <th mat-header-cell *matHeaderCellDef> Symbol </th> <td mat-cell *matCellDef="let element"> {{element.symbol}} </td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table> </section>
{ "end_byte": 1152, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-header/table-sticky-header-example.html" }
components/src/components-examples/material/table/table-sticky-header/table-sticky-header-example.ts_0_1253
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; /** * @title Table with sticky header */ @Component({ selector: 'table-sticky-header-example', styleUrl: 'table-sticky-header-example.css', templateUrl: 'table-sticky-header-example.html', imports: [MatTableModule], }) export class TableStickyHeaderExample { displayedColumns = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA; } export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ];
{ "end_byte": 1253, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-header/table-sticky-header-example.ts" }
components/src/components-examples/material/table/table-sticky-header/table-sticky-header-example.css_0_84
.example-container { height: 400px; overflow: auto; } table { width: 100%; }
{ "end_byte": 84, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-header/table-sticky-header-example.css" }
components/src/components-examples/material/table/table-dynamic-columns/table-dynamic-columns-example.html_0_670
<button mat-raised-button (click)="addColumn()"> Add column </button> <button mat-raised-button (click)="removeColumn()"> Remove column </button> <button mat-raised-button (click)="shuffle()"> Shuffle </button> <table mat-table [dataSource]="data" class="mat-elevation-z8"> @for (column of displayedColumns; track column) { <ng-container [matColumnDef]="column"> <th mat-header-cell *matHeaderCellDef> {{column}} </th> <td mat-cell *matCellDef="let element"> {{element[column]}} </td> </ng-container> } <tr mat-header-row *matHeaderRowDef="columnsToDisplay"></tr> <tr mat-row *matRowDef="let row; columns: columnsToDisplay;"></tr> </table>
{ "end_byte": 670, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-dynamic-columns/table-dynamic-columns-example.html" }
components/src/components-examples/material/table/table-dynamic-columns/table-dynamic-columns-example.ts_0_2123
import {Component} from '@angular/core'; import {MatTableModule} from '@angular/material/table'; import {MatButtonModule} from '@angular/material/button'; export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ]; /** * @title Table dynamically changing the columns displayed */ @Component({ selector: 'table-dynamic-columns-example', styleUrl: 'table-dynamic-columns-example.css', templateUrl: 'table-dynamic-columns-example.html', imports: [MatButtonModule, MatTableModule], }) export class TableDynamicColumnsExample { displayedColumns: string[] = ['name', 'weight', 'symbol', 'position']; columnsToDisplay: string[] = this.displayedColumns.slice(); data: PeriodicElement[] = ELEMENT_DATA; addColumn() { const randomColumn = Math.floor(Math.random() * this.displayedColumns.length); this.columnsToDisplay.push(this.displayedColumns[randomColumn]); } removeColumn() { if (this.columnsToDisplay.length) { this.columnsToDisplay.pop(); } } shuffle() { let currentIndex = this.columnsToDisplay.length; while (0 !== currentIndex) { let randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; // Swap let temp = this.columnsToDisplay[currentIndex]; this.columnsToDisplay[currentIndex] = this.columnsToDisplay[randomIndex]; this.columnsToDisplay[randomIndex] = temp; } } }
{ "end_byte": 2123, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-dynamic-columns/table-dynamic-columns-example.ts" }
components/src/components-examples/material/table/table-dynamic-columns/table-dynamic-columns-example.css_0_57
table { width: 100%; } button { margin: 16px 8px; }
{ "end_byte": 57, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-dynamic-columns/table-dynamic-columns-example.css" }
components/src/components-examples/material/table/table-sticky-complex-flex/table-sticky-complex-flex-example.css_0_807
.example-container { height: 400px; overflow: auto; } .mat-mdc-table-sticky { background: #59abfd; opacity: 1; } .example-sticky-toggle-group { margin: 8px; } .mat-column-filler { padding: 0 8px; font-size: 10px; text-align: center; } .mat-mdc-header-cell, .mat-mdc-footer-cell, .mat-mdc-cell { min-width: 80px; box-sizing: border-box; } .mat-mdc-header-row, .mat-mdc-footer-row, .mat-mdc-row { min-width: 1920px; /* 24 columns, 80px each */ } .mat-mdc-table-sticky-border-elem-top { border-bottom: 2px solid midnightblue; } .mat-mdc-table-sticky-border-elem-right { border-left: 2px solid midnightblue; } .mat-mdc-table-sticky-border-elem-bottom { border-top: 2px solid midnightblue; } .mat-mdc-table-sticky-border-elem-left { border-right: 2px solid midnightblue; }
{ "end_byte": 807, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-complex-flex/table-sticky-complex-flex-example.css" }
components/src/components-examples/material/table/table-sticky-complex-flex/table-sticky-complex-flex-example.html_0_3855
<div> <button mat-raised-button (click)="tables.push(tables.length)">Add table</button> <button mat-raised-button (click)="tables.pop()">Remove table</button> </div> <div> Sticky Headers: <mat-button-toggle-group multiple [value]="['header-1']" #stickyHeaders="matButtonToggleGroup" class="example-sticky-toggle-group"> <mat-button-toggle value="header-1"> Row 1 </mat-button-toggle> <mat-button-toggle value="header-2"> Row 2 </mat-button-toggle> </mat-button-toggle-group> </div> <div> Sticky Footers: <mat-button-toggle-group multiple [value]="['footer-1']" #stickyFooters="matButtonToggleGroup" class="example-sticky-toggle-group"> <mat-button-toggle value="footer-1"> Row 1 </mat-button-toggle> <mat-button-toggle value="footer-2"> Row 2 </mat-button-toggle> </mat-button-toggle-group> </div> <div> Sticky Columns: <mat-button-toggle-group multiple [value]="['position', 'symbol']" #stickyColumns="matButtonToggleGroup" class="example-sticky-toggle-group"> <mat-button-toggle value="position"> Position </mat-button-toggle> <mat-button-toggle value="name"> Name </mat-button-toggle> <mat-button-toggle value="weight"> Weight </mat-button-toggle> <mat-button-toggle value="symbol"> Symbol </mat-button-toggle> </mat-button-toggle-group> </div> <section class="example-container mat-elevation-z8" tabindex="0"> @for (table of tables; track table) { <mat-table [dataSource]="dataSource"> <ng-container matColumnDef="position" [sticky]="isSticky(stickyColumns, 'position')"> <mat-header-cell *matHeaderCellDef> Position </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.position}} </mat-cell> <mat-footer-cell *matFooterCellDef> Position Footer </mat-footer-cell> </ng-container> <ng-container matColumnDef="name" [sticky]="isSticky(stickyColumns, 'name')"> <mat-header-cell *matHeaderCellDef> Name </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.name}} </mat-cell> <mat-footer-cell *matFooterCellDef> Name Footer </mat-footer-cell> </ng-container> <ng-container matColumnDef="weight" [stickyEnd]="isSticky(stickyColumns, 'weight')"> <mat-header-cell *matHeaderCellDef> Weight </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.weight}} </mat-cell> <mat-footer-cell *matFooterCellDef> Weight Footer </mat-footer-cell> </ng-container> <ng-container matColumnDef="symbol" [stickyEnd]="isSticky(stickyColumns, 'symbol')"> <mat-header-cell *matHeaderCellDef> Symbol </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.symbol}} </mat-cell> <mat-footer-cell *matFooterCellDef> Symbol Footer </mat-footer-cell> </ng-container> <ng-container matColumnDef="filler"> <mat-header-cell *matHeaderCellDef> Filler header cell </mat-header-cell> <mat-cell *matCellDef="let element"> Filler data cell </mat-cell> <mat-footer-cell *matFooterCellDef> Filler footer cell </mat-footer-cell> </ng-container> <mat-header-row *matHeaderRowDef="displayedColumns; sticky: isSticky(stickyHeaders, 'header-1')"></mat-header-row> <mat-header-row *matHeaderRowDef="displayedColumns; sticky: isSticky(stickyHeaders, 'header-2')"></mat-header-row> <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> <mat-footer-row *matFooterRowDef="displayedColumns; sticky: isSticky(stickyFooters, 'footer-1')"></mat-footer-row> <mat-footer-row *matFooterRowDef="displayedColumns; sticky: isSticky(stickyFooters, 'footer-2')"></mat-footer-row> </mat-table> } </section>
{ "end_byte": 3855, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-complex-flex/table-sticky-complex-flex-example.html" }
components/src/components-examples/material/table/table-sticky-complex-flex/table-sticky-complex-flex-example.ts_0_2081
import {Component} from '@angular/core'; import {MatButtonToggleGroup, MatButtonToggleModule} from '@angular/material/button-toggle'; import {MatTableModule} from '@angular/material/table'; import {MatButtonModule} from '@angular/material/button'; /** * @title Flex-layout tables with toggle-able sticky headers, footers, and columns */ @Component({ selector: 'table-sticky-complex-flex-example', styleUrl: 'table-sticky-complex-flex-example.css', templateUrl: 'table-sticky-complex-flex-example.html', imports: [MatButtonModule, MatButtonToggleModule, MatTableModule], }) export class TableStickyComplexFlexExample { displayedColumns: string[] = []; dataSource = ELEMENT_DATA; tables = [0]; constructor() { this.displayedColumns.length = 24; this.displayedColumns.fill('filler'); // The first two columns should be position and name; the last two columns: weight, symbol this.displayedColumns[0] = 'position'; this.displayedColumns[1] = 'name'; this.displayedColumns[22] = 'weight'; this.displayedColumns[23] = 'symbol'; } /** Whether the button toggle group contains the id as an active value. */ isSticky(buttonToggleGroup: MatButtonToggleGroup, id: string) { return (buttonToggleGroup.value || []).indexOf(id) !== -1; } } export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; } const ELEMENT_DATA: PeriodicElement[] = [ {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, ];
{ "end_byte": 2081, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-sticky-complex-flex/table-sticky-complex-flex-example.ts" }
components/src/components-examples/material/table/table-expandable-rows/table-expandable-rows-example.css_0_713
table { width: 100%; } tr.example-detail-row { height: 0; } tr.example-element-row:not(.example-expanded-row):hover { background: whitesmoke; } tr.example-element-row:not(.example-expanded-row):active { background: #efefef; } .example-element-row td { border-bottom-width: 0; } .example-element-detail { overflow: hidden; display: flex; } .example-element-diagram { min-width: 80px; border: 2px solid black; padding: 8px; font-weight: lighter; margin: 8px 0; height: 104px; } .example-element-symbol { font-weight: bold; font-size: 40px; line-height: normal; } .example-element-description { padding: 16px; } .example-element-description-attribution { opacity: 0.5; }
{ "end_byte": 713, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-expandable-rows/table-expandable-rows-example.css" }
components/src/components-examples/material/table/table-expandable-rows/table-expandable-rows-example.html_0_2298
<table mat-table [dataSource]="dataSource" multiTemplateDataRows class="mat-elevation-z8"> @for (column of columnsToDisplay; track column) { <ng-container matColumnDef="{{column}}"> <th mat-header-cell *matHeaderCellDef> {{column}} </th> <td mat-cell *matCellDef="let element"> {{element[column]}} </td> </ng-container> } <ng-container matColumnDef="expand"> <th mat-header-cell *matHeaderCellDef aria-label="row actions">&nbsp;</th> <td mat-cell *matCellDef="let element"> <button mat-icon-button aria-label="expand row" (click)="(expandedElement = expandedElement === element ? null : element); $event.stopPropagation()"> @if (expandedElement === element) { <mat-icon>keyboard_arrow_up</mat-icon> } @else { <mat-icon>keyboard_arrow_down</mat-icon> } </button> </td> </ng-container> <!-- Expanded Content Column - The detail row is made up of this one column that spans across all columns --> <ng-container matColumnDef="expandedDetail"> <td mat-cell *matCellDef="let element" [attr.colspan]="columnsToDisplayWithExpand.length"> <div class="example-element-detail" [@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'"> <div class="example-element-diagram"> <div class="example-element-position"> {{element.position}} </div> <div class="example-element-symbol"> {{element.symbol}} </div> <div class="example-element-name"> {{element.name}} </div> <div class="example-element-weight"> {{element.weight}} </div> </div> <div class="example-element-description"> {{element.description}} <span class="example-element-description-attribution"> -- Wikipedia </span> </div> </div> </td> </ng-container> <tr mat-header-row *matHeaderRowDef="columnsToDisplayWithExpand"></tr> <tr mat-row *matRowDef="let element; columns: columnsToDisplayWithExpand;" class="example-element-row" [class.example-expanded-row]="expandedElement === element" (click)="expandedElement = expandedElement === element ? null : element"> </tr> <tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="example-detail-row"></tr> </table>
{ "end_byte": 2298, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-expandable-rows/table-expandable-rows-example.html" }
components/src/components-examples/material/table/table-expandable-rows/table-expandable-rows-example.ts_0_4503
import {Component} from '@angular/core'; import {animate, state, style, transition, trigger} from '@angular/animations'; import {MatIconModule} from '@angular/material/icon'; import {MatButtonModule} from '@angular/material/button'; import {MatTableModule} from '@angular/material/table'; /** * @title Table with expandable rows */ @Component({ selector: 'table-expandable-rows-example', styleUrl: 'table-expandable-rows-example.css', templateUrl: 'table-expandable-rows-example.html', animations: [ trigger('detailExpand', [ state('collapsed,void', style({height: '0px', minHeight: '0'})), state('expanded', style({height: '*'})), transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')), ]), ], imports: [MatTableModule, MatButtonModule, MatIconModule], }) export class TableExpandableRowsExample { dataSource = ELEMENT_DATA; columnsToDisplay = ['name', 'weight', 'symbol', 'position']; columnsToDisplayWithExpand = [...this.columnsToDisplay, 'expand']; expandedElement: PeriodicElement | null; } export interface PeriodicElement { name: string; position: number; weight: number; symbol: string; description: string; } const ELEMENT_DATA: PeriodicElement[] = [ { position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H', description: `Hydrogen is a chemical element with symbol H and atomic number 1. With a standard atomic weight of 1.008, hydrogen is the lightest element on the periodic table.`, }, { position: 2, name: 'Helium', weight: 4.0026, symbol: 'He', description: `Helium is a chemical element with symbol He and atomic number 2. It is a colorless, odorless, tasteless, non-toxic, inert, monatomic gas, the first in the noble gas group in the periodic table. Its boiling point is the lowest among all the elements.`, }, { position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li', description: `Lithium is a chemical element with symbol Li and atomic number 3. It is a soft, silvery-white alkali metal. Under standard conditions, it is the lightest metal and the lightest solid element.`, }, { position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be', description: `Beryllium is a chemical element with symbol Be and atomic number 4. It is a relatively rare element in the universe, usually occurring as a product of the spallation of larger atomic nuclei that have collided with cosmic rays.`, }, { position: 5, name: 'Boron', weight: 10.811, symbol: 'B', description: `Boron is a chemical element with symbol B and atomic number 5. Produced entirely by cosmic ray spallation and supernovae and not by stellar nucleosynthesis, it is a low-abundance element in the Solar system and in the Earth's crust.`, }, { position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C', description: `Carbon is a chemical element with symbol C and atomic number 6. It is nonmetallic and tetravalent—making four electrons available to form covalent chemical bonds. It belongs to group 14 of the periodic table.`, }, { position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N', description: `Nitrogen is a chemical element with symbol N and atomic number 7. It was first discovered and isolated by Scottish physician Daniel Rutherford in 1772.`, }, { position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O', description: `Oxygen is a chemical element with symbol O and atomic number 8. It is a member of the chalcogen group on the periodic table, a highly reactive nonmetal, and an oxidizing agent that readily forms oxides with most elements as well as with other compounds.`, }, { position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F', description: `Fluorine is a chemical element with symbol F and atomic number 9. It is the lightest halogen and exists as a highly toxic pale yellow diatomic gas at standard conditions.`, }, { position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne', description: `Neon is a chemical element with symbol Ne and atomic number 10. It is a noble gas. Neon is a colorless, odorless, inert monatomic gas under standard conditions, with about two-thirds the density of air.`, }, ];
{ "end_byte": 4503, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/table/table-expandable-rows/table-expandable-rows-example.ts" }
components/src/components-examples/material/list/BUILD.bazel_0_1045
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite") package(default_visibility = ["//visibility:public"]) ng_module( name = "list", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), assets = glob([ "**/*.html", "**/*.css", ]), deps = [ "//src/cdk/testing", "//src/cdk/testing/testbed", "//src/material/icon", "//src/material/list", "//src/material/list/testing", "@npm//@angular/platform-browser", "@npm//@types/jasmine", ], ) filegroup( name = "source-files", srcs = glob([ "**/*.html", "**/*.css", "**/*.ts", ]), ) ng_test_library( name = "unit_tests_lib", srcs = glob(["**/*.spec.ts"]), deps = [ ":list", "//src/cdk/testing", "//src/cdk/testing/testbed", "//src/material/list", "//src/material/list/testing", ], ) ng_web_test_suite( name = "unit_tests", deps = [":unit_tests_lib"], )
{ "end_byte": 1045, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/BUILD.bazel" }
components/src/components-examples/material/list/index.ts_0_611
export {ListOverviewExample} from './list-overview/list-overview-example'; export {ListSectionsExample} from './list-sections/list-sections-example'; export {ListSelectionExample} from './list-selection/list-selection-example'; export {ListSingleSelectionExample} from './list-single-selection/list-single-selection-example'; export {ListSingleSelectionReactiveFormExample} from './list-single-selection-reactive-form/list-single-selection-reactive-form-example'; export {ListHarnessExample} from './list-harness/list-harness-example'; export {ListVariantsExample} from './list-variants/list-variants-example';
{ "end_byte": 611, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/index.ts" }
components/src/components-examples/material/list/list-single-selection-reactive-form/list-single-selection-form-example.html_0_366
<form [formGroup]="form"> <mat-selection-list #shoesList [formControl]="shoesControl" name="shoes" [multiple]="false"> @for (shoe of shoes; track shoe) { <mat-list-option [value]="shoe.value">{{shoe.name}}</mat-list-option> } </mat-selection-list> <p> Option selected: {{shoesControl.value ? shoesControl.value[0] : 'None'}} </p> </form>
{ "end_byte": 366, "start_byte": 0, "url": "https://github.com/angular/components/blob/main/src/components-examples/material/list/list-single-selection-reactive-form/list-single-selection-form-example.html" }