Fix wrong dataSource

This commit is contained in:
kevinpauer 2022-04-05 19:43:35 +02:00
parent 4c7506d8b2
commit 7c5c993d2f
2 changed files with 20 additions and 6 deletions

View File

@ -7,28 +7,36 @@
</div>
<mat-card class="placeholder">
<div class="stockTable">
<table mat-table [dataSource]="dataSourceTransactions">
<table mat-table [dataSource]="dataSourceStocks">
<!--- 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 -->
<!-- Symbol Column -->
<ng-container matColumnDef="position">
<th mat-header-cell *matHeaderCellDef>Symbol</th>
<td mat-cell *matCellDef="let element">{{ element.symbol }}</td>
</ng-container>
<!-- Name Column -->
<!-- Count Column -->
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Count</th>
<td mat-cell *matCellDef="let element">{{ element.count }}</td>
</ng-container>
<!-- Weight Column -->
<!-- Time Column -->
<ng-container matColumnDef="weight">
<th mat-header-cell *matHeaderCellDef>Time</th>
<td mat-cell *matCellDef="let element">{{ element.time }}</td>
</ng-container>
<!-- Time Column -->
<ng-container matColumnDef="current-price">
<th mat-header-cell *matHeaderCellDef>Current Price</th>
<td mat-cell *matCellDef="let element">
{{ element.currentPrice }}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumnsStocks"></tr>
<tr
mat-row

View File

@ -12,7 +12,7 @@ export interface PeriodicElement {
export interface Stock {
count: number;
// price: number;
currentPrice: number;
symbol: string;
time: string;
}
@ -53,6 +53,7 @@ export class DashboardComponent implements OnInit {
for (let i = 0; i < data.data.length; i++) {
STOCK_DATA.push({
count: data.data[i].count,
currentPrice: data.data[i].current_price,
symbol: data.data[i].symbol,
time: data.data[i].last_transaction,
});
@ -101,6 +102,11 @@ export class DashboardComponent implements OnInit {
}
displayedColumns: string[] = ['weight', 'position', 'name', 'symbol'];
displayedColumnsStocks: string[] = ['position', 'name', 'weight'];
displayedColumnsStocks: string[] = [
'position',
'name',
'weight',
'current-price',
];
dataSource = ELEMENT_DATA;
}