Last active
December 27, 2020 00:20
-
-
Save d4rkc0de/7aed56eb45c48c2c5c675b61bf2c0bdb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// styles.scss | |
@import '~@angular/material/prebuilt-themes/indigo-pink.css'; | |
// HTML | |
<mat-table class="lessons-table mat-elevation-z8" [dataSource]="dataSource"> | |
<ng-container matColumnDef="id"> | |
<mat-header-cell *matHeaderCellDef>#</mat-header-cell> | |
<mat-cell *matCellDef="let customer">{{customer.id}}</mat-cell> | |
</ng-container> | |
<ng-container matColumnDef="name"> | |
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell> | |
<mat-cell class="description-cell" | |
*matCellDef="let customer">{{customer.name}} | |
</mat-cell> | |
</ng-container> | |
<ng-container matColumnDef="age"> | |
<mat-header-cell *matHeaderCellDef>Age</mat-header-cell> | |
<mat-cell class="duration-cell" | |
*matCellDef="let customer">{{customer.age}} | |
</mat-cell> | |
</ng-container> | |
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> | |
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row> | |
</mat-table> | |
// Component.ts | |
export class AppComponent implements OnInit { | |
displayedColumns = ["id", "name", "age"]; | |
dataSource: MatTableDataSource<any> = new MatTableDataSource(); | |
public data = [{ id: 1, name: "Hi", age: 25 }, { id: 2, name: "Lol", age: 35 }]; | |
ngOnInit(): void { | |
this.dataSource.data = this.data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment