I have a datatable with mock data and multiple rows and an add button in the end to add a new row. The problem is when there is no data in the table, I mean no rows, the add button doesn't add the initial row?
I took this as a reference: here
My stackblitz code: here
app.component.ts
triggerAdd() {
this.addMode = !this.addMode;
}
onRowAddSave(customer: any) {
if(Object.keys(customer).length !== 0 ){
this.launchMaturity.push(customer);
this.formatProduct(this.launchMaturity);
this.addMode = false;
this.newAttribute = {};
}
}
onRowCancelSave() {
this.addMode = false;
}
}
public formatProduct(value: any) {
this.formatData = [];
this.exportable = true;
value.map((a: any) => this.formatData.push(a));
}
}
public launchMaturity: any[];