I have a mat-table that renders data dynamically like this:
<ng-container matColumnDef="type">
<mat-header-cell *matHeaderCellDef> No. </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.type}} </mat-cell>
</ng-container>
<ng-container matColumnDef="count">
<mat-header-cell *matHeaderCellDef> Count </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.count}} </mat-cell>
</ng-container>
I dont have count in the model i am querying the number of items from the back end and returning the count by grouping how many each type has using aggregate function and $group. the types (electronics, households...) are in the collection ..
[{_id: objectId type: electronics}
{_id: objectId type: households}
]
after aggregate and grouping query i get this array back
[
{type: electronics count: 139},
{type: households count: 400},
...
]
I want to add a count column that counts the number of different items where electronics will be its own row and return 139 in the count column and household its own row and return 400
I am successfully in logging the data returned from the backend but how do i display it on mat table.
Using angular 5 material how do I iterate through the mat-cell and grab each type (electronic, households from a different cell) and display the count for that type on its respective row? any suggestion would be appreciated!