I have a list of entries. When I click on such an entry a HTTP request is done, data will be loaded and presented in a table. So far so good.
Now I try to create an export function to output all tables at once. The abstracted code looks like this:
this.objectlist.forEach(entry => {
this.getDataFromHTTP(entry).subscribe(response => {
tabledata.push(this.getTableDOM());
})
})
In the function getTableDOM()
I do something like let table = document.getElementsByClassName(data.classname);
. The code itself runs when I click every entry. But it doesn't work within the forEach()
.
The real problem is that the getTableDOM()
returns an empty result, because the DOM isn't ready when it is called.
So my question is: how can I wait until DOM changes are done before I call getTableDOM()
. Or maybe my approach to achieve my goal is completely wrong. But if so: how can I do it otherwise?
Thx for your help! Lars