I´m trying to create a dynamic table with pdfmake and Angular5/Ionic3. As table data I need some data from firebase snapshot. So in case I have an observable.
What I tried
Subscribing observable and save data
this.streetDetailData
.take(1)
.subscribe(data => {
bodyData.push(data);
});
pdfmake definition
content: [
{ text: `${this.sStreet.street}${this.sStreet.parentPLZ ? ', ' + this.sStreet.parentPLZ : ''}, ${this.sStreet.parentCountry}`, style: 'header' },
{ text: moment().format('LL'), style: 'date'},
this.table(bodyData, ['number', 'status'])
],
table function
table(data, columns) {
return {
table: {
headerRows: 1,
body: this.buildTableBody(data, columns)
}
};
}
buldTableBody function
buildTableBody(data, columns) {
let body = [];
body.push(columns);
data.forEach((row) => {
console.log(row);
let dataRow = [];
columns.forEach(function(column) {
dataRow.push(row[column].toString());
});
body.push(dataRow);
});
return body;
}
But no chance...I´m always getting an empty result... Where´s the error?
That´s what I see in the generated PDF: