My application allows users to upload files, perform backend operations, and receive a list of JSON Objects in return. I have created a material table to display this data. However, I am facing an issue where the dataSource of my material table is not updating correctly. When I upload a file and view the data, it displays correctly. But when I upload a different file and view the content again, it still shows the data from the first file uploaded initially. I understand that the problem lies in not subscribing the dataSource to the changes sent by the server, even though I have tried adding the subscription without success. Can someone please assist me with resolving this issue?
test-table-datasource.ts
// Code for TestTableDataSource goes here...
test-table.component.ts
// Code for TestTableComponent goes here...
test-table.component.html
<div class="mat-elevation-z8">
<table mat-table class="full-width-table" matSort aria-label="Elements">
// Table columns code goes here...
</table>
<mat-paginator #paginator
[length]="dataSource?.data.length"
[pageIndex]="0"
[pageSize]="2"
[pageSizeOptions]="[2, 3, 5, 25, 50, 100, 250]">
</mat-paginator>
</div>
I have looked at some solutions online but they don't apply directly to my situation since I used CLI to generate the table. As a beginner in Angular, any help would be greatly appreciated. Thank you!