Guest User

Untitled

a guest
Jan 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. <mat-table #table [dataSource]="dataSource">
  2. <ng-container matColumnDef="id">
  3. <mat-header-cell *matHeaderCellDef> ID </mat-header-cell>
  4. <mat-cell *matCellDef="let element"> {{element.id}} </mat-cell>
  5. </ng-container>
  6.  
  7. <ng-container matColumnDef="name">
  8. <mat-header-cell *matHeaderCellDef> Name </mat-header-cell>
  9. <mat-cell *matCellDef="let element"> {{element.name}} </mat-cell>
  10. </ng-container>
  11.  
  12. <ng-container matColumnDef="symbol">
  13. <mat-header-cell *matHeaderCellDef> Symbol </mat-header-cell>
  14. <mat-cell *matCellDef="let element"> {{element.symbol}} </mat-cell>
  15. </ng-container>
  16.  
  17.  
  18. <!-- ----------------- -->
  19. <!-- The delete column -->
  20. <ng-container matColumnDef="delete">
  21. <mat-header-cell *matHeaderCellDef></mat-header-cell>
  22.  
  23. <!-- the "strike-ignore" class will allow this cell to be visable over the strike -->
  24. <mat-cell *matCellDef="let element" class="strike-ignore">
  25.  
  26. <!-- You can do this differently, but the toBeDeleted property allows the button to
  27. switch between delete and undo icons. -->
  28. <button mat-raised-button [ngClass]="element.toBeDeleted ? 'sec-btn' : 'del-btn'" (click)="deleteElement(element)">
  29. <mat-icon class="btn-icon" [svgIcon]="element.toBeDeleted ? 'undo' : 'delete'"></mat-icon>
  30. </button>
  31. </mat-cell>
  32. </ng-container>
  33.  
  34. <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
  35.  
  36. <!-- I add the "strike" class to rows with the following JS that finds it by the element ID:
  37. const element = document.getElementById(item.id) as HTMLElement;
  38. element.classList.add('strike'); -->
  39. <mat-row [id]="element.id" *matRowDef="let element; let row; columns: displayedColumns;"></mat-row>
  40. </mat-table>
Add Comment
Please, Sign In to add comment