'How do I integrate angular material components in ngx admin project
I have a ngx admin project in angular and I want to include a material component in one of the pages.
I tried installing material using "ng add @angular/material" which gives an error.
So then I included @import "~@angular/material/prebuilt-themes/indigo-pink.css"; into styles.css
This is my html code that I want to integrate in one of the pages of angular material. The project shoes no errors, but whenever I run it, the page doesnt open. The html isnt displayed and everything goes into some kind of error.
<button mat-button (click)="openDialog('Add',{})" mat-flat-button color="primary">Add Row</button>
<table mat-table [dataSource]="dataSource" #mytable class="my-table 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" -->
<!-- Id Column -->
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> ID. </th>
<td mat-cell *matCellDef="let element"> {{element.id}} </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>
<!-- Action Column -->
<ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef> Action </th>
<td mat-cell *matCellDef="let element" class="action-link">
<a (click)="openDialog('Update',element)">Edit</a> |
<a (click)="openDialog('Delete',element)">Delete</a>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|