Hello, I hope it serves you and is what you are looking for
Ts. – You have to create a function that will return the json key
Make sure the first object contains all the headers you require so that you avoid problems.
For the next try to adapt the code that is given to what you need, do not expect someone to solve it completely.
if you can see it is the same code literally just add a path of object.keys to be able to send the fix that requires the ngx-datatable for the headers
Are you using Ionic 4 and Typescript ?
On my side i’ve this error:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property ‘push’ of undefined
TypeError: Cannot read property ‘push’ of undefined
at tab5.page.ts:129
at Array.forEach ()
header(dat) {
let h: any [];
const listHeader: any = Object.keys(dat);
listHeader.forEach(item => {
h.push({ name: item }); // line 129
});
return h;
}
Don’t worry I like to help.
I see you have a error…
So you can push the variable you need to initialize the variable in an empty array.
look what if you don’t start the variable in an empty array
header(dat) {
let h:any =[] //array to title columns
let listHeader: any = Object.keys(dat) //getting the headings and adding
listHeader.forEach(item => { //scanning the array of titles
h.push({ name: item }) //adding the titles to the list
})
return h //retuning list
}