I have implement table using MatTableModule in angular using typescripts.
It is working fine when I assign value to datasource like this,
let dataRow = {name: dealerInfo.name, address: dealerInfo.address, town: dealerInfo.town, contact:dealerInfo.contact};
this.dataSource = [dataRow];
As I need to add rows dynamically I used push() as follows (but it doesn't work, it does not show data in the html),
let dataRow = {name: dealerInfo.name, address: dealerInfo.address, town: dealerInfo.town, contact:dealerInfo.contact};
this.dataSource.push(dataRow);
This is how my data source defined.
dataSource: any [] = [];
What should be the correct way of adding elements dynamically?
this.dataSource = [...this.dataSource, dataRow];work? In that case it's Angular's change detector that doesn't pick up the call topush.